From f7e332cbba25f6845a22a2b80a8cb6e32b78ced4 Mon Sep 17 00:00:00 2001 From: Marvin Hemmer Date: Mon, 16 Mar 2026 11:52:32 +0100 Subject: [PATCH] [PWGEM] PM: Overhaul NonLin with new centrality dependent paramenter approach. - Non Lin now uses correction of type a + b * refVal^(-c). Each parameter (a,b, and c) are described by a linear function of centrality. This makes 6 meta parameters (2 meta parameters for each parameter). Those 6 meta parameters are stored in a TMatrixD in the CCDB, where the number of rows marks the number of iterations. - Add default values for V0PhotonCandidate. - Remove `using namespace` from `PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h` --- PWGEM/PhotonMeson/Core/EMNonLin.cxx | 54 +-- PWGEM/PhotonMeson/Core/EMNonLin.h | 336 +++++------------- .../PhotonMeson/Core/MaterialBudgetWeights.h | 27 +- PWGEM/PhotonMeson/Core/V0PhotonCandidate.h | 99 +++--- .../TableProducer/nonLinProducer.cxx | 44 ++- .../TableProducer/photonconversionbuilder.cxx | 1 + 6 files changed, 208 insertions(+), 353 deletions(-) diff --git a/PWGEM/PhotonMeson/Core/EMNonLin.cxx b/PWGEM/PhotonMeson/Core/EMNonLin.cxx index 571d7efbae8..5c44ecc9f0c 100644 --- a/PWGEM/PhotonMeson/Core/EMNonLin.cxx +++ b/PWGEM/PhotonMeson/Core/EMNonLin.cxx @@ -16,56 +16,40 @@ #include "EMNonLin.h" #include +#include using namespace o2::pwgem::nonlin; -float EMNonLin::getCorrectionFactor(float x, const Context& ctx) +float EMNonLin::getCorrectionFactor(float var, const Context& ctx) { - if (!ctx.params || x == 0.f) [[unlikely]] { - return x; + if (!ctx.params || var == 0.f) [[unlikely]] { + return 1.f; } int maxIter = std::min(ctx.nIter, MaxIter - 1); - - float scale = 1.f; // cumulative scale - float refVal = x; // reference value for computing next scale + float scale = 1.f; // cumulative scale + float refVal = var; // reference value updated each iteration for (int i = 0; i <= maxIter; ++i) { if (refVal == 0.f) { break; } - const auto& p = ctx.params[i]; - // scale function (x + a + b/x)/(x + c) which goes towards 1 for large x since x >> a,b,c -> x/x = 1 - float iterScale = - (refVal + p.par0 + p.par1 / refVal) / - (refVal + p.par2); + // evaluate pol1 for each parameter at this centrality + float a = p.a0 + p.a1 * ctx.cent; + float b = p.b0 + p.b1 * ctx.cent; + float c = p.c0 + p.c1 * ctx.cent; - scale *= iterScale; // total scale = product over itertaion scale - refVal = x * scale; // next iteration uses scaled original input - } - return scale; -} - -const EMNonLin::NonLinParams* EMNonLin::resolveParams(PhotonType type, float cent) -{ - int centBin = static_cast(cent / 10.f); - if (centBin < 0) - centBin = 0; - if (centBin >= CentBins) - centBin = CentBins - 1; - - return &kNonLinTable[static_cast(type)][centBin][0]; -} + // guard against c <= 0 which would make pow(x, -c) diverge + if (c <= 0.f) { + continue; + } -const EMNonLin::NonLinParams* EMNonLin::resolveParamsMC(PhotonType type, float cent) -{ - int centBin = static_cast(cent / 10.f); - if (centBin < 0) - centBin = 0; - if (centBin >= CentBins) - centBin = CentBins - 1; + float iterScale = a + b * std::pow(refVal, -c); + scale *= iterScale; + refVal = var * scale; // next iteration uses scaled original input + } - return &kNonLinTableMC[static_cast(type)][centBin][0]; + return scale; } diff --git a/PWGEM/PhotonMeson/Core/EMNonLin.h b/PWGEM/PhotonMeson/Core/EMNonLin.h index e9bce15c260..d272d9e5593 100644 --- a/PWGEM/PhotonMeson/Core/EMNonLin.h +++ b/PWGEM/PhotonMeson/Core/EMNonLin.h @@ -18,290 +18,134 @@ #include -#include // uint8_t +#include + +#include +#include namespace o2::pwgem::nonlin { +constexpr int MaxCent = 100.f; + /// \class EMNonLin /// \brief Class to obtain non linear correction factors for PbPb. +/// Parameters are loaded from CCDB (TMatrixD: rows = iterations, cols = 6 pol1 coefficients). +/// Falls back to hardcoded static table if CCDB object is not available. +/// The correction is of type a + b * refVal^(-c), where a, b and c are themselves described by linear functions over centrality. class EMNonLin { public: - static constexpr int MaxIter = 2; + static constexpr int MaxIter = 2; // hard cap on iterations static constexpr int PhotonN = 3; - static constexpr int CentBins = 10; + static constexpr int NCols = 6; // a0, a1, b0, b1, c0, c1 enum class PhotonType : uint8_t { kEMC = 0, kPCM = 1, - kPHOS = 2 // just in case + kPHOS = 2 }; struct NonLinParams { - float par0{0.f}; - float par1{0.f}; - float par2{0.f}; + float a0{1.f}, a1{0.f}; // pol1 params for a: asymptote + float b0{0.f}, b1{0.f}; // pol1 params for b: magnitude + float c0{0.f}, c1{0.f}; // pol1 params for c: exponent }; struct Context { const NonLinParams* params = nullptr; int nIter = 0; + float cent = 0.f; + /// \brief Sets parameters for the NonLin. Used with EMNonLin::resolveParams() + /// \param newParams pointer to new NonLinParams void setParams(const NonLinParams* newParams) { params = newParams; } + /// \brief Sets iteration used for the NonLin. + /// \param iter iteration void setIter(int iter) { - if (iter < 0 || iter >= MaxIter) { - nIter = MaxIter - 1; - return; - } + nIter = (iter < 0 || iter >= MaxIter) ? MaxIter - 1 : iter; + } - nIter = iter; + /// \brief Sets current centrality. + /// \param centrality centrality + void setCent(float centrality) + { + cent = (centrality >= MaxCent) ? MaxCent : centrality; } }; - /// \brief gets the correction value for energy or pT for a specific - /// \param inputCalibValue pT or energy of the photon that needs calibration - /// \param ctx Context which has the centrality, photontype and number of iterations stored inside - static float getCorrectionFactor(float inputCalibValue, const Context& ctx); - - /// \brief sets the parameters accordingly to the photon type, centrality and the wanted iteration level - /// \param photonType type of the photon (e.g. 0 for EMC) - /// \param cent centrality of the current collision in case the correction is centrality dependent - static const NonLinParams* resolveParams(PhotonType type, float cent); - - /// \brief sets the parameters accordingly to the photon type, centrality and the wanted iteration level for MC - /// \param photonType type of the photon (e.g. 0 for EMC) - /// \param cent centrality of the current collision in case the correction is centrality dependent - static const NonLinParams* resolveParamsMC(PhotonType type, float cent); + /// \brief Load parameters from a TMatrixD fetched from CCDB. + /// Rows = iterations, cols = {a0, a1, b0, b1, c0, c1}. + /// Overwrites the static fallback for this photon type. + /// \param mat pointer to TMatrixD from CCDB (may be nullptr) + /// \param type photon type to fill + void getFromCCDBObject(const TMatrixD* mat, PhotonType type) + { + int iType = static_cast(type); + if (!mat || mat->GetNcols() != NCols) { + mCCDBLoaded[iType] = false; + return; + } + int nIter = std::min(mat->GetNrows(), MaxIter); + for (int i = 0; i < nIter; ++i) { + mCCDBParams[iType][i] = { + static_cast((*mat)(i, 0)), static_cast((*mat)(i, 1)), + static_cast((*mat)(i, 2)), static_cast((*mat)(i, 3)), + static_cast((*mat)(i, 4)), static_cast((*mat)(i, 5))}; + } + mCCDBLoaded[iType] = true; + } + + /// \brief Compute the multiplicative correction factor for energy/pT. + /// \param par energy or pT of the photon + /// \param ctx context holding centrality, iteration level, and params pointer + static float getCorrectionFactor(float var, const Context& ctx); + + /// \brief Return pointer to the params array for a given photon type. + /// \returns CCDB-loaded params if available, otherwise the static fallback. + const NonLinParams* resolveParams(PhotonType type) const + { + int iType = static_cast(type); + return mCCDBLoaded[iType] ? &mCCDBParams[iType][0] : &FallbackTable[iType][0]; + } private: - static constexpr NonLinParams kNonLinTable - [PhotonN][CentBins][MaxIter] = - { - // ============================ - // PhotonType::kEMC (0) - // ============================ - { - // 00–10 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, // iter 0 - {0.f, 0.f, 0.f} // iter 1 - }, - // 10–20 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 20–30 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 30–40 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 40–50 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 50–60 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 60–70 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 70–80 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 80–90 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 90–100 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}}, - - // ============================ - // PhotonType::kPCM (1) - // ============================ - { - // 00–10 - { - {10.7203f, 0.0383968f, 10.6025f}, // iter 0 - {7.84549f, 0.0250021f, 7.86976f} // iter 1 - }, - // 10–20 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 20–30 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 30–40 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 40–50 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 50–60 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 60–70 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 70–80 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 80–90 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 90–100 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}}, - - // ============================ - // PhotonType::kPHOS (2) - // ============================ - { - // All centralities identical - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}}}; - - static constexpr NonLinParams kNonLinTableMC - [PhotonN][CentBins][MaxIter] = - { - // ============================ - // PhotonType::kEMC (0) - // ============================ - { - // 00–10 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, // iter 0 - {0.f, 0.f, 0.f} // iter 1 - }, - // 10–20 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 20–30 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 30–40 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 40–50 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 50–60 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 60–70 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 70–80 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 80–90 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}, - // 90–100 - { - {-5.33426e-01f, 1.40144e-02f, -5.24434e-01f}, - {0.f, 0.f, 0.f}}}, - - // ============================ - // PhotonType::kPCM (1) - // ============================ - { - // 00–10 - { - {10.7203f, 0.0383968f, 10.6025f}, // iter 0 - {7.84549f, 0.0250021f, 7.86976f} // iter 1 - }, - // 10–20 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 20–30 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 30–40 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 40–50 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 50–60 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 60–70 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 70–80 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 80–90 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}, - // 90–100 - { - {10.7203f, 0.0383968f, 10.6025f}, - {7.84549f, 0.0250021f, 7.86976f}}}, + NonLinParams mCCDBParams[PhotonN][MaxIter] = {}; // Runtime params loaded from CCDB (per photon type, per iteration) + bool mCCDBLoaded[PhotonN] = {false, false, false}; + + // ------------------------------------------------------- + // Static fallback tables (used when CCDB object is absent) + // ------------------------------------------------------- + static constexpr NonLinParams FallbackTable[PhotonN][MaxIter] = { + // kEMC + {{1.f, 0.f, 0.f, 0.f, 0.f, 0.f}, + {1.f, 0.f, 0.f, 0.f, 0.f, 0.f}}, + // kPCM + {{1.f, 0.f, 0.010417f, -1.09508e-05f, 0.355795f, 0.00427618f}, + {1.f, 0.f, 0.f, 0.f, 0.f, 0.f}}, + // kPHOS + {{1.f, 0.f, 0.f, 0.f, 0.f, 0.f}, + {1.f, 0.f, 0.f, 0.f, 0.f, 0.f}}, + }; - // ============================ - // PhotonType::kPHOS (2) - // ============================ - { - // All centralities identical - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}, - {{0.f, 0.f, 0.f}, {0.f, 0.f, 0.f}}}}; + static constexpr NonLinParams FallbackTableMC[PhotonN][MaxIter] = { + // kEMC + {{1.f, 0.f, 0.f, 0.f, 0.f, 0.f}, + {1.f, 0.f, 0.f, 0.f, 0.f, 0.f}}, + // kPCM + {{1.f, 0.f, 0.010417f, -1.09508e-05f, 0.355795f, 0.00427618f}, + {1.f, 0.f, 0.f, 0.f, 0.f, 0.f}}, + // kPHOS + {{1.f, 0.f, 0.f, 0.f, 0.f, 0.f}, + {1.f, 0.f, 0.f, 0.f, 0.f, 0.f}}, + }; }; + } // namespace o2::pwgem::nonlin #endif // PWGEM_PHOTONMESON_CORE_EMNONLIN_H_ diff --git a/PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h b/PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h index 41f4169f3bb..094f86ceb8a 100644 --- a/PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h +++ b/PWGEM/PhotonMeson/Core/MaterialBudgetWeights.h @@ -8,47 +8,40 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// -/// \file materialBudgetWeights.cxx -/// + +/// \file MaterialBudgetWeights.h /// \brief This code produces a table to retrieve material budget weights. The table is to be join with V0PhotonKF -/// /// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch) -/// #ifndef PWGEM_PHOTONMESON_CORE_MATERIALBUDGETWEIGHTS_H_ #define PWGEM_PHOTONMESON_CORE_MATERIALBUDGETWEIGHTS_H_ #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/Logger.h" #include +#include +#include +#include #include #include +#include #include #include -using namespace o2; -using namespace o2::soa; -using namespace o2::framework; - using MyV0PhotonsMB = o2::soa::Join; using MyV0PhotonMB = MyV0PhotonsMB::iterator; struct MaterialBudgetWeights { - Produces omegaMBWeight; + o2::framework::Produces omegaMBWeight; - Configurable ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "CCDB url"}; - Configurable mbWeightsPath{"mbWeightsPath", "Users/y/yelmard/MaterialBudget/OmegaMBWeights", "Path of the mb weights"}; + o2::framework::Configurable ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "CCDB url"}; + o2::framework::Configurable mbWeightsPath{"mbWeightsPath", "Users/y/yelmard/MaterialBudget/OmegaMBWeights", "Path of the mb weights"}; o2::ccdb::CcdbApi ccdbApi; TH1F* hOmegaMBFromCCDB = nullptr; - void init(InitContext&) + void init(o2::framework::InitContext&) { // Load CCDB object only when the real process is enabled if (!doprocessMC) { diff --git a/PWGEM/PhotonMeson/Core/V0PhotonCandidate.h b/PWGEM/PhotonMeson/Core/V0PhotonCandidate.h index c29925b4bfb..2e98a0396b5 100644 --- a/PWGEM/PhotonMeson/Core/V0PhotonCandidate.h +++ b/PWGEM/PhotonMeson/Core/V0PhotonCandidate.h @@ -16,7 +16,6 @@ #ifndef PWGEM_PHOTONMESON_CORE_V0PHOTONCANDIDATE_H_ #define PWGEM_PHOTONMESON_CORE_V0PHOTONCANDIDATE_H_ -#include "PWGEM/Dilepton/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" #include "Common/Core/RecoDecay.h" @@ -228,55 +227,55 @@ struct V0PhotonCandidate { CentType getCentType() const { return centType; } private: - float conversionPointx; - float conversionPointy; - float conversionPointz; - float px; - float py; - float pz; - float posPx; - float posPy; - float posPz; - float elePx; - float elePy; - float elePz; - float pT; - float posPT; - float elePT; - float dcaXYV0ToPV; - float dcaZV0ToPV; - float alpha; - float qt; - float phiv; - float psipair; - float cospa; - float cospaRZ; - float cospaXY; - float chi2ndf; - float cent; - float pca; - float eta; - float posEta; - float eleEta; - float posdcaXY; - float posdcaZ; - float eledcaXY; - float eledcaZ; - float posTPCNClsShared; - float posTPCNClsFindable; - float posTPCNClsFindableMinusShared; - float posTPCNClsFindableMinusCrossedRows; - float posTPCChi2NCl; - float posTPCSignal; - float posITSClusterSizes; - float eleTPCNClsShared; - float eleTPCNClsFindable; - float eleTPCNClsFindableMinusShared; - float eleTPCNClsFindableMinusCrossedRows; - float eleTPCChi2NCl; - float eleTPCSignal; - float eleITSClusterSizes; - CentType centType; + float conversionPointx{0.f}; + float conversionPointy{0.f}; + float conversionPointz{0.f}; + float px{0.f}; + float py{0.f}; + float pz{0.f}; + float posPx{0.f}; + float posPy{0.f}; + float posPz{0.f}; + float elePx{0.f}; + float elePy{0.f}; + float elePz{0.f}; + float pT{0.f}; + float posPT{0.f}; + float elePT{0.f}; + float dcaXYV0ToPV{0.f}; + float dcaZV0ToPV{0.f}; + float alpha{0.f}; + float qt{0.f}; + float phiv{0.f}; + float psipair{0.f}; + float cospa{0.f}; + float cospaRZ{0.f}; + float cospaXY{0.f}; + float chi2ndf{0.f}; + float cent{0.f}; + float pca{0.f}; + float eta{0.f}; + float posEta{0.f}; + float eleEta{0.f}; + float posdcaXY{0.f}; + float posdcaZ{0.f}; + float eledcaXY{0.f}; + float eledcaZ{0.f}; + float posTPCNClsShared{0.f}; + float posTPCNClsFindable{0.f}; + float posTPCNClsFindableMinusShared{0.f}; + float posTPCNClsFindableMinusCrossedRows{0.f}; + float posTPCChi2NCl{0.f}; + float posTPCSignal{0.f}; + float posITSClusterSizes{0.f}; + float eleTPCNClsShared{0.f}; + float eleTPCNClsFindable{0.f}; + float eleTPCNClsFindableMinusShared{0.f}; + float eleTPCNClsFindableMinusCrossedRows{0.f}; + float eleTPCChi2NCl{0.f}; + float eleTPCSignal{0.f}; + float eleITSClusterSizes{0.f}; + CentType centType{CentFT0C}; }; #endif // PWGEM_PHOTONMESON_CORE_V0PHOTONCANDIDATE_H_ diff --git a/PWGEM/PhotonMeson/TableProducer/nonLinProducer.cxx b/PWGEM/PhotonMeson/TableProducer/nonLinProducer.cxx index 9feae005b6d..3e8d6cb146f 100644 --- a/PWGEM/PhotonMeson/TableProducer/nonLinProducer.cxx +++ b/PWGEM/PhotonMeson/TableProducer/nonLinProducer.cxx @@ -20,6 +20,7 @@ #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h" +#include #include #include #include @@ -29,7 +30,10 @@ #include #include +#include + #include +#include #include using namespace o2; @@ -54,6 +58,9 @@ struct NonLinProducer { Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3)"}; Configurable emcIteration{"emcIteration", 0, "iteration number of the non lin correction for EMCal. 0 means first iteration 1 means second and so on!"}; Configurable pcmIteration{"pcmIteration", 0, "iteration number of the non lin correction for PCM. 0 means first iteration 1 means second and so on!"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathEmcal{"ccdbPathEmcal", "Users/m/mhemmer/EM/NonLin/EMC", "CCDB Path to Non Lin TMatrixD for EMCal"}; + Configurable ccdbPathPcm{"ccdbPathPcm", "Users/m/mhemmer/EM/NonLin/PCM", "CCDB Path to Non Lin TMatrixD for PCM"}; HistogramRegistry historeg{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; @@ -68,6 +75,11 @@ struct NonLinProducer { EMNonLin::Context emNonLinContextEMC; EMNonLin::Context emNonLinContextPCM; + o2::framework::Service ccdb; + + TMatrixD* emcalMatrix = nullptr; + TMatrixD* pcmMatrix = nullptr; + void init(o2::framework::InitContext&) { historeg.add("QA/EMC/EIn", "Energy of EMC clusters before NonLin correction", gHistoSpecClusterE); @@ -81,6 +93,26 @@ struct NonLinProducer { emNonLinContextEMC.setIter(emcIteration); emNonLinContextPCM.setIter(pcmIteration); + + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + } + + template + void initCCDB(TCollision const& collision) + { + if (doprocessEMC) { + emcalMatrix = ccdb->getForTimeStamp(ccdbPathEmcal, collision.timestamp()); + emNonLinEMC.getFromCCDBObject(emcalMatrix, o2::pwgem::nonlin::EMNonLin::PhotonType::kEMC); + emNonLinContextEMC.setParams(emNonLinEMC.resolveParams(o2::pwgem::nonlin::EMNonLin::PhotonType::kEMC)); + } + if (doprocessPCM) { + pcmMatrix = ccdb->getForTimeStamp(ccdbPathPcm, collision.timestamp()); + emNonLinPCM.getFromCCDBObject(pcmMatrix, o2::pwgem::nonlin::EMNonLin::PhotonType::kPCM); + emNonLinContextPCM.setParams(emNonLinPCM.resolveParams(o2::pwgem::nonlin::EMNonLin::PhotonType::kPCM)); + } } /// Get the centrality @@ -113,7 +145,7 @@ struct NonLinProducer { int32_t collIndex = collision.globalIndex(); float cent = getCentrality(collision); - emNonLinContextEMC.setParams(emNonLinEMC.resolveParams(o2::pwgem::nonlin::EMNonLin::PhotonType::kEMC, cent)); + emNonLinContextEMC.setCent(cent); for (const auto& cluster : clusters) { @@ -122,7 +154,7 @@ struct NonLinProducer { collIndex = cluster.pmeventId(); collision.setCursor(collIndex); cent = getCentrality(collision); - emNonLinContextEMC.setParams(emNonLinEMC.resolveParams(o2::pwgem::nonlin::EMNonLin::PhotonType::kEMC, cent)); + emNonLinContextEMC.setCent(cent); } // fill before non lin histograms @@ -149,7 +181,7 @@ struct NonLinProducer { int32_t collIndex = collision.globalIndex(); float cent = getCentrality(collision); - emNonLinContextPCM.setParams(emNonLinPCM.resolveParams(o2::pwgem::nonlin::EMNonLin::PhotonType::kPCM, cent)); + emNonLinContextPCM.setCent(cent); for (const auto& v0 : v0s) { // check that we are at the correct collision @@ -157,14 +189,14 @@ struct NonLinProducer { collIndex = v0.pmeventId(); collision.setCursor(collIndex); cent = getCentrality(collision); - emNonLinContextPCM.setParams(emNonLinPCM.resolveParams(o2::pwgem::nonlin::EMNonLin::PhotonType::kPCM, cent)); + emNonLinContextPCM.setCent(cent); } // fill before non lin histograms historeg.fill(HIST("QA/PCM/PtIn"), v0.pt()); // get NonLin factor from class dependent on the centrality - float nonLinFactor = emNonLinEMC.getCorrectionFactor(v0.pt(), emNonLinContextPCM); + float nonLinFactor = emNonLinPCM.getCorrectionFactor(v0.pt(), emNonLinContextPCM); float nonLinPt = nonLinFactor * v0.pt(); @@ -183,6 +215,7 @@ struct NonLinProducer { } auto collision = collisions.begin(); + initCCDB(collision); runEMC(emcclusters, collision); } PROCESS_SWITCH(NonLinProducer, processEMC, "Create Non Lin table for EMC.", false); @@ -193,6 +226,7 @@ struct NonLinProducer { return; } auto collision = collisions.begin(); + initCCDB(collision); runPCM(pcmPhotons, collision); } PROCESS_SWITCH(NonLinProducer, processPCM, "Create Non Lin table for PCM.", false); diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx index 33dd3e0ae31..9b2f9e0c411 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx @@ -18,6 +18,7 @@ #define HomogeneousField // needed for KFParticle::SetField(magneticField); #endif +#include "PWGEM/Dilepton/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/Core/EmMlResponsePCM.h" #include "PWGEM/PhotonMeson/Core/V0PhotonCandidate.h" #include "PWGEM/PhotonMeson/Core/V0PhotonCut.h"