From 581ad1b32bcbdf1d789ec3e707edd2d1d3e9c8c6 Mon Sep 17 00:00:00 2001 From: Ionut Cristian Arsene Date: Wed, 4 Jun 2025 09:55:40 +0200 Subject: [PATCH 1/5] Adding a guard if constexpr for TOF n-sigma's in the VarManager --- PWGDQ/Core/VarManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index d49e71677da..65cf64cb27f 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -2523,7 +2523,7 @@ void VarManager::FillTrack(T const& track, float* values) values[kTPCnSigmaPr_Corr] = track.tpcNSigmaPr(); } } - + if constexpr ((fillMap & TrackPID) > 0 || (fillMap & ReducedTrackBarrelPID) > 0) { values[kTOFnSigmaEl] = track.tofNSigmaEl(); values[kTOFnSigmaPi] = track.tofNSigmaPi(); From 519d5d6dfda660513c7816b1f3d79da7680ed3fb Mon Sep 17 00:00:00 2001 From: Ionut Cristian Arsene Date: Wed, 13 Aug 2025 14:52:34 +0200 Subject: [PATCH 2/5] Removed TPC randomized pid quantities from VarManager --- PWGDQ/Core/CutsLibrary.cxx | 49 -------------------------------------- PWGDQ/Core/VarManager.cxx | 8 ------- PWGDQ/Core/VarManager.h | 24 ------------------- 3 files changed, 81 deletions(-) diff --git a/PWGDQ/Core/CutsLibrary.cxx b/PWGDQ/Core/CutsLibrary.cxx index 20a4c7c548f..ee152f11b6b 100644 --- a/PWGDQ/Core/CutsLibrary.cxx +++ b/PWGDQ/Core/CutsLibrary.cxx @@ -1476,34 +1476,6 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) } } - //--------------------------------------------------------------------------------------- - // NOTE: Below there are several TPC pid cuts used for studies of the dE/dx degradation - // and its impact on the high lumi pp quarkonia triggers - // To be removed when not needed anymore - if (!nameStr.compare("jpsiPID1Randomized")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine")); // standard kine cuts usually are applied via Filter in the task - cut->AddCut(GetAnalysisCut("electronStandardQuality")); - cut->AddCut(GetAnalysisCut("standardPrimaryTrack")); - cut->AddCut(GetAnalysisCut("electronPID1randomized")); - return cut; - } - - if (!nameStr.compare("jpsiPID2Randomized")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine")); - cut->AddCut(GetAnalysisCut("electronStandardQuality")); - cut->AddCut(GetAnalysisCut("standardPrimaryTrack")); - cut->AddCut(GetAnalysisCut("electronPID2randomized")); - return cut; - } - - if (!nameStr.compare("jpsiPIDnsigmaRandomized")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine")); - cut->AddCut(GetAnalysisCut("electronStandardQuality")); - cut->AddCut(GetAnalysisCut("standardPrimaryTrack")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaRandomized")); - return cut; - } - if (!nameStr.compare("jpsiPIDworseRes")) { cut->AddCut(GetAnalysisCut("jpsiStandardKine")); cut->AddCut(GetAnalysisCut("electronStandardQuality")); @@ -5136,13 +5108,6 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } - if (!nameStr.compare("electronPID1randomized")) { - cutLow1->SetParameters(130., -40.0); - cut->AddCut(VarManager::kTPCsignalRandomized, 70., 100.); - cut->AddCut(VarManager::kTPCsignalRandomized, cutLow1, 100.0, false, VarManager::kPin, 0.5, 3.0); - return cut; - } - if (!nameStr.compare("electronPID2")) { cutLow1->SetParameters(130., -40.0); cut->AddCut(VarManager::kTPCsignal, 73., 100.); @@ -5157,13 +5122,6 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } - if (!nameStr.compare("electronPID2randomized")) { - cutLow1->SetParameters(130., -40.0); - cut->AddCut(VarManager::kTPCsignalRandomized, 73., 100.); - cut->AddCut(VarManager::kTPCsignalRandomized, cutLow1, 100.0, false, VarManager::kPin, 0.5, 3.0); - return cut; - } - if (!nameStr.compare("electronPIDnsigma")) { cut->AddCut(VarManager::kTPCnSigmaEl, -3.0, 3.0); cut->AddCut(VarManager::kTPCnSigmaPr, 3.0, 3000.0); @@ -5645,13 +5603,6 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } - if (!nameStr.compare("electronPIDnsigmaRandomized")) { - cut->AddCut(VarManager::kTPCnSigmaElRandomized, -3.0, 3.0); - cut->AddCut(VarManager::kTPCnSigmaPrRandomized, 3.0, 3000.0); - cut->AddCut(VarManager::kTPCnSigmaPiRandomized, 3.0, 3000.0); - return cut; - } - if (!nameStr.compare("electronPIDworseRes")) { cut->AddCut(VarManager::kTPCnSigmaEl, -3.0, 3.0); cut->AddCut(VarManager::kTPCnSigmaPr, 3.0 * 0.8, 3000.0); // emulates a 20% degradation in PID resolution diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 4bb8c419ad7..e7f39661612 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -1451,8 +1451,6 @@ void VarManager::SetDefaultVarNames() fgVarNamesMap["kTPCnCRoverFindCls"] = kTPCnCRoverFindCls; fgVarNamesMap["kTPCchi2"] = kTPCchi2; fgVarNamesMap["kTPCsignal"] = kTPCsignal; - fgVarNamesMap["kTPCsignalRandomized"] = kTPCsignalRandomized; - fgVarNamesMap["kTPCsignalRandomizedDelta"] = kTPCsignalRandomizedDelta; fgVarNamesMap["kPhiTPCOuter"] = kPhiTPCOuter; fgVarNamesMap["kTrackIsInsideTPCModule"] = kTrackIsInsideTPCModule; fgVarNamesMap["kTRDsignal"] = kTRDsignal; @@ -1476,20 +1474,14 @@ void VarManager::SetDefaultVarNames() fgVarNamesMap["kTrackCTglTgl"] = kTrackCTglTgl; fgVarNamesMap["kTrackC1Pt21Pt2"] = kTrackC1Pt21Pt2; fgVarNamesMap["kTPCnSigmaEl"] = kTPCnSigmaEl; - fgVarNamesMap["kTPCnSigmaElRandomized"] = kTPCnSigmaElRandomized; - fgVarNamesMap["kTPCnSigmaElRandomizedDelta"] = kTPCnSigmaElRandomizedDelta; fgVarNamesMap["kTPCnSigmaMu"] = kTPCnSigmaMu; fgVarNamesMap["kTPCnSigmaPi"] = kTPCnSigmaPi; - fgVarNamesMap["kTPCnSigmaPiRandomized"] = kTPCnSigmaPiRandomized; - fgVarNamesMap["kTPCnSigmaPiRandomizedDelta"] = kTPCnSigmaPiRandomizedDelta; fgVarNamesMap["kTPCnSigmaKa"] = kTPCnSigmaKa; fgVarNamesMap["kTPCnSigmaPr"] = kTPCnSigmaPr; fgVarNamesMap["kTPCnSigmaEl_Corr"] = kTPCnSigmaEl_Corr; fgVarNamesMap["kTPCnSigmaPi_Corr"] = kTPCnSigmaPi_Corr; fgVarNamesMap["kTPCnSigmaKa_Corr"] = kTPCnSigmaKa_Corr; fgVarNamesMap["kTPCnSigmaPr_Corr"] = kTPCnSigmaPr_Corr; - fgVarNamesMap["kTPCnSigmaPrRandomized"] = kTPCnSigmaPrRandomized; - fgVarNamesMap["kTPCnSigmaPrRandomizedDelta"] = kTPCnSigmaPrRandomizedDelta; fgVarNamesMap["kTOFnSigmaEl"] = kTOFnSigmaEl; fgVarNamesMap["kTOFnSigmaMu"] = kTOFnSigmaMu; fgVarNamesMap["kTOFnSigmaPi"] = kTOFnSigmaPi; diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 65cf64cb27f..4af7d02b570 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -506,8 +506,6 @@ class VarManager : public TObject kTPCnCRoverFindCls, kTPCchi2, kTPCsignal, - kTPCsignalRandomized, - kTPCsignalRandomizedDelta, kPhiTPCOuter, kTrackIsInsideTPCModule, kTRDsignal, @@ -531,20 +529,14 @@ class VarManager : public TObject kTrackCTglTgl, kTrackC1Pt21Pt2, kTPCnSigmaEl, - kTPCnSigmaElRandomized, - kTPCnSigmaElRandomizedDelta, kTPCnSigmaMu, kTPCnSigmaPi, - kTPCnSigmaPiRandomized, - kTPCnSigmaPiRandomizedDelta, kTPCnSigmaKa, kTPCnSigmaPr, kTPCnSigmaEl_Corr, kTPCnSigmaPi_Corr, kTPCnSigmaKa_Corr, kTPCnSigmaPr_Corr, - kTPCnSigmaPrRandomized, - kTPCnSigmaPrRandomizedDelta, kTOFnSigmaEl, kTOFnSigmaMu, kTOFnSigmaPi, @@ -2531,22 +2523,6 @@ void VarManager::FillTrack(T const& track, float* values) values[kTOFnSigmaPr] = track.tofNSigmaPr(); } - if (fgUsedVars[kTPCsignalRandomized] || fgUsedVars[kTPCnSigmaElRandomized] || fgUsedVars[kTPCnSigmaPiRandomized] || fgUsedVars[kTPCnSigmaPrRandomized]) { - // NOTE: this is needed temporarily for the study of the impact of TPC pid degradation on the quarkonium triggers in high lumi pp - // This study involves a degradation from a dE/dx resolution of 5% to one of 6% (20% worsening) - // For this we smear the dE/dx and n-sigmas using a gaus distribution with a width of 3.3% - // which is approx the needed amount to get dE/dx to a resolution of 6% - double randomX = gRandom->Gaus(0.0, 0.033); - values[kTPCsignalRandomized] = values[kTPCsignal] * (1.0 + randomX); - values[kTPCsignalRandomizedDelta] = values[kTPCsignal] * randomX; - values[kTPCnSigmaElRandomized] = values[kTPCnSigmaEl] * (1.0 + randomX); - values[kTPCnSigmaElRandomizedDelta] = values[kTPCnSigmaEl] * randomX; - values[kTPCnSigmaPiRandomized] = values[kTPCnSigmaPi] * (1.0 + randomX); - values[kTPCnSigmaPiRandomizedDelta] = values[kTPCnSigmaPi] * randomX; - values[kTPCnSigmaPrRandomized] = values[kTPCnSigmaPr] * (1.0 + randomX); - values[kTPCnSigmaPrRandomizedDelta] = values[kTPCnSigmaPr] * randomX; - } - if constexpr ((fillMap & ReducedTrackBarrelPID) > 0) { values[kTPCnSigmaMu] = track.tpcNSigmaMu(); values[kTOFnSigmaMu] = track.tofNSigmaMu(); From dbeda0c9e9aa9218bb25e21a9e9f992b3c05e4a7 Mon Sep 17 00:00:00 2001 From: Ionut Cristian Arsene Date: Wed, 13 Aug 2025 18:42:41 +0200 Subject: [PATCH 3/5] Implemented a new TPC pid postcalibration type for PbPb collisions --- PWGDQ/Core/VarManager.cxx | 2 + PWGDQ/Core/VarManager.h | 232 +++++++++++++------ PWGDQ/TableProducer/tableMaker_withAssoc.cxx | 12 + PWGDQ/Tasks/tableReader_withAssoc.cxx | 8 + 4 files changed, 189 insertions(+), 65 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index e7f39661612..e2a138dec89 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -45,6 +45,8 @@ o2::vertexing::FwdDCAFitterN<3> VarManager::fgFitterThreeProngFwd; o2::globaltracking::MatchGlobalFwd VarManager::mMatching; std::map VarManager::fgCalibs; bool VarManager::fgRunTPCPostCalibration[4] = {false, false, false, false}; +int VarManager::fgCalibrationType = 0; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb +bool VarManager::fgUseInterpolatedCalibration = true; // use interpolated calibration histograms (default: true) //__________________________________________________________________ VarManager::VarManager() : TObject() diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 4af7d02b570..e48a8aa0ca9 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -858,12 +858,16 @@ class VarManager : public TObject enum CalibObjects { kTPCElectronMean = 0, kTPCElectronSigma, + kTPCElectronStatus, kTPCPionMean, kTPCPionSigma, + kTPCPionStatus, kTPCKaonMean, kTPCKaonSigma, + kTPCKaonStatus, kTPCProtonMean, kTPCProtonSigma, + kTPCProtonStatus, kNCalibObjects }; @@ -1148,6 +1152,16 @@ class VarManager : public TObject fgUsedVars[kTPCnSigmaPr_Corr] = true; } } + + static void SetCalibrationType(int type, bool useInterpolation = true) + { + if (type < 0 || type > 2) { + LOG(fatal) << "Invalid calibration type. Must be 0, 1, or 2."); + } + fgCalibrationType = type; + fgUseInterpolatedCalibration = useInterpolation; + } + static TObject* GetCalibrationObject(CalibObjects calib) { auto obj = fgCalibs.find(calib); @@ -1223,11 +1237,13 @@ class VarManager : public TObject static std::map fgCalibs; // map of calibration histograms static bool fgRunTPCPostCalibration[4]; // 0-electron, 1-pion, 2-kaon, 3-proton + static int fgCalibrationType; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb + static bool fgUseInterpolatedCalibration; // use interpolated calibration histograms (default: true) VarManager& operator=(const VarManager& c); VarManager(const VarManager& c); - ClassDef(VarManager, 3); + ClassDef(VarManager, 4); }; template @@ -1362,6 +1378,146 @@ o2::dataformats::GlobalFwdTrack VarManager::PropagateMuon(const T& muon, const C return propmuon; } +double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { + // species: 0 - electron, 1 - pion, 2 - kaon, 3 - proton + // Depending on the PID calibration type, we use different types of calibration histograms + + if (fgCalibrationType == 1) { + // get the calibration histograms + CalibObjects calibMean, calibSigma; + switch (species) { + case 0: + calibMean = kTPCElectronMean; + calibSigma = kTPCElectronSigma; + break; + case 1: + calibMean = kTPCPionMean; + calibSigma = kTPCPionSigma; + break; + case 2: + calibMean = kTPCKaonMean; + calibSigma = kTPCKaonSigma; + break; + case 3: + calibMean = kTPCProtonMean; + calibSigma = kTPCProtonSigma; + break; + default: + LOG(fatal) << "Invalid species for PID calibration: " << species; + return -999.0; // Return zero if species is invalid + }; + + TH3F* calibMeanHist = reinterpret_cast(fgCalibs[calibMean]); + TH3F* calibSigmaHist = reinterpret_cast(fgCalibs[calibSigma]); + if (!calibMeanHist || !calibSigmaHist) { + LOG(fatal) << "Calibration histograms not found for species: " << species; + return -999.0; // Return zero if histograms are not found + } + + // Get the bin indices for the calibration histograms + int binTPCncls = calibMeanHist->GetXaxis()->FindBin(fgValues[kTPCncls]); + binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); + binTPCncls = (binTPCncls > calibMeanHist->GetXaxis()->GetNbins() ? calibMeanHist->GetXaxis()->GetNbins() : binTPCncls); + int binPin = calibMeanHist->GetYaxis()->FindBin(fgValues[kPin]); + binPin = (binPin == 0 ? 1 : binPin); + binPin = (binPin > calibMeanHist->GetYaxis()->GetNbins() ? calibMeanHist->GetYaxis()->GetNbins() : binPin); + int binEta = calibMeanHist->GetZaxis()->FindBin(fgValues[kEta]); + binEta = (binEta == 0 ? 1 : binEta); + binEta = (binEta > calibMeanHist->GetZaxis()->GetNbins() ? calibMeanHist->GetZaxis()->GetNbins() : binEta); + + double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta); + double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta); + return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value + } + else if (fgCalibrationType == 2) { + // get the calibration histograms + CalibObjects calibMean, calibSigma, calibStatus; + switch (species) { + case 0: + calibMean = kTPCElectronMean; + calibSigma = kTPCElectronSigma; + calibStatus = kTPCElectronStatus; + break; + case 1: + calibMean = kTPCPionMean; + calibSigma = kTPCPionSigma; + calibStatus = kTPCPionStatus; + break; + case 2: + calibMean = kTPCKaonMean; + calibSigma = kTPCKaonSigma; + calibStatus = kTPCKaonStatus; + break; + case 3: + calibMean = kTPCProtonMean; + calibSigma = kTPCProtonSigma; + calibStatus = kTPCProtonStatus; + break; + default: + LOG(fatal) << "Invalid species for PID calibration: " << species; + return -999.0; // Return zero if species is invalid + }; + + THnF* calibMeanHist = reinterpret_cast(fgCalibs[calibMean]); + THnF* calibSigmaHist = reinterpret_cast(fgCalibs[calibSigma]); + THnF* calibStatusHist = reinterpret_cast(fgCalibs[calibStatus]); + if (!calibMeanHist || !calibSigmaHist || !calibStatusHist) { + LOG(fatal) << "Calibration histograms not found for species: " << species; + return -999.0; // Return zero if histograms are not found + } + + // Get the bin indices for the calibration histograms + int binEta = calibMeanHist->GetAxis(0)->FindBin(fgValues[kEta]); + binEta = (binEta == 0 ? 1 : binEta); + binEta = (binEta > calibMeanHist->GetAxis(0)->GetNbins() ? calibMeanHist->GetAxis(0)->GetNbins() : binEta); + int binNpv = calibMeanHist->GetAxis(1)->FindBin(fgValues[kVtxNcontribReal]); + binNpv = (binNpv == 0 ? 1 : binNpv); + binNpv = (binNpv > calibMeanHist->GetAxis(1)->GetNbins() ? calibMeanHist->GetAxis(1)->GetNbins() : binNpv); + int binNlong = calibMeanHist->GetAxis(2)->FindBin(fgValues[kNTPCcontribLongA]); + binNlong = (binNlong == 0 ? 1 : binNlong); + binNlong = (binNlong > calibMeanHist->GetAxis(2)->GetNbins() ? calibMeanHist->GetAxis(2)->GetNbins() : binNlong); + int binTlong = calibMeanHist->GetAxis(3)->FindBin(fgValues[kNTPCmedianTimeLongA]); + binTlong = (binTlong == 0 ? 1 : binTlong); + binTlong = (binTlong > calibMeanHist->GetAxis(3)->GetNbins() ? calibMeanHist->GetAxis(3)->GetNbins() : binTlong); + + int bin[4] = {binEta, binNpv, binNlong, binTlong}; + int status = reinterpret_cast(calibStatusHist->GetBinContent(bin)); + double mean = calibMeanHist->GetBinContent(bin); + double sigma = calibSigmaHist->GetBinContent(bin); + switch (status) { + case 0: + // good calibration, return the calibrated nSigma value + return (nSigmaValue - mean) / sigma; + break; + case 1: + // calibration not valid, return the original nSigma value + return nSigmaValue; + break; + case 2: // calibration constant has poor stat uncertainty, consider the user option for what to do + case 3: + // calibration constants have been interpolated + if (fgUseInterpolatedCalibration) { + return (nSigmaValue - mean) / sigma; + } else { + // return the original nSigma value + return nSigmaValue; + } + break; + case 4: + // calibration constants interpolation failed, return the original nSigma value + return nSigmaValue; + break; + default: + return nSigmaValue; // unknown status, return the original nSigma value + break; + }; + } else { + // unknown calibration type, return the original nSigma value + LOG(fatal) << "Unknown calibration type: " << fgCalibrationType; + return nSigmaValue; // Return the original nSigma value + } +} + template void VarManager::FillMuonPDca(const T& muon, const C& collision, float* values) { @@ -2426,92 +2582,38 @@ void VarManager::FillTrack(T const& track, float* values) } // compute TPC postcalibrated electron nsigma based on calibration histograms from CCDB if (fgUsedVars[kTPCnSigmaEl_Corr] && fgRunTPCPostCalibration[0]) { - TH3F* calibMean = reinterpret_cast(fgCalibs[kTPCElectronMean]); - TH3F* calibSigma = reinterpret_cast(fgCalibs[kTPCElectronSigma]); - - int binTPCncls = calibMean->GetXaxis()->FindBin(values[kTPCncls]); - binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); - binTPCncls = (binTPCncls > calibMean->GetXaxis()->GetNbins() ? calibMean->GetXaxis()->GetNbins() : binTPCncls); - int binPin = calibMean->GetYaxis()->FindBin(values[kPin]); - binPin = (binPin == 0 ? 1 : binPin); - binPin = (binPin > calibMean->GetYaxis()->GetNbins() ? calibMean->GetYaxis()->GetNbins() : binPin); - int binEta = calibMean->GetZaxis()->FindBin(values[kEta]); - binEta = (binEta == 0 ? 1 : binEta); - binEta = (binEta > calibMean->GetZaxis()->GetNbins() ? calibMean->GetZaxis()->GetNbins() : binEta); - - double mean = calibMean->GetBinContent(binTPCncls, binPin, binEta); - double width = calibSigma->GetBinContent(binTPCncls, binPin, binEta); if (!isTPCCalibrated) { - values[kTPCnSigmaEl_Corr] = (values[kTPCnSigmaEl] - mean) / width; + values[kTPCnSigmaEl_Corr] = ComputePIDcalibration(0, values[kTPCnSigmaEl]); } else { + LOG(fatal) << "TPC PID postcalibration is configured but the tracks are already postcalibrated. This is not allowed. Please check your configuration."; values[kTPCnSigmaEl_Corr] = track.tpcNSigmaEl(); } } + // compute TPC postcalibrated pion nsigma if required if (fgUsedVars[kTPCnSigmaPi_Corr] && fgRunTPCPostCalibration[1]) { - TH3F* calibMean = reinterpret_cast(fgCalibs[kTPCPionMean]); - TH3F* calibSigma = reinterpret_cast(fgCalibs[kTPCPionSigma]); - - int binTPCncls = calibMean->GetXaxis()->FindBin(values[kTPCncls]); - binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); - binTPCncls = (binTPCncls > calibMean->GetXaxis()->GetNbins() ? calibMean->GetXaxis()->GetNbins() : binTPCncls); - int binPin = calibMean->GetYaxis()->FindBin(values[kPin]); - binPin = (binPin == 0 ? 1 : binPin); - binPin = (binPin > calibMean->GetYaxis()->GetNbins() ? calibMean->GetYaxis()->GetNbins() : binPin); - int binEta = calibMean->GetZaxis()->FindBin(values[kEta]); - binEta = (binEta == 0 ? 1 : binEta); - binEta = (binEta > calibMean->GetZaxis()->GetNbins() ? calibMean->GetZaxis()->GetNbins() : binEta); - - double mean = calibMean->GetBinContent(binTPCncls, binPin, binEta); - double width = calibSigma->GetBinContent(binTPCncls, binPin, binEta); if (!isTPCCalibrated) { - values[kTPCnSigmaPi_Corr] = (values[kTPCnSigmaPi] - mean) / width; + values[kTPCnSigmaPi_Corr] = ComputePIDcalibration(1, values[kTPCnSigmaPi]); } else { + LOG(fatal) << "TPC PID postcalibration is configured but the tracks are already postcalibrated. This is not allowed. Please check your configuration."; values[kTPCnSigmaPi_Corr] = track.tpcNSigmaPi(); } } if (fgUsedVars[kTPCnSigmaKa_Corr] && fgRunTPCPostCalibration[2]) { - TH3F* calibMean = reinterpret_cast(fgCalibs[kTPCKaonMean]); - TH3F* calibSigma = reinterpret_cast(fgCalibs[kTPCKaonSigma]); - - int binTPCncls = calibMean->GetXaxis()->FindBin(values[kTPCncls]); - binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); - binTPCncls = (binTPCncls > calibMean->GetXaxis()->GetNbins() ? calibMean->GetXaxis()->GetNbins() : binTPCncls); - int binPin = calibMean->GetYaxis()->FindBin(values[kPin]); - binPin = (binPin == 0 ? 1 : binPin); - binPin = (binPin > calibMean->GetYaxis()->GetNbins() ? calibMean->GetYaxis()->GetNbins() : binPin); - int binEta = calibMean->GetZaxis()->FindBin(values[kEta]); - binEta = (binEta == 0 ? 1 : binEta); - binEta = (binEta > calibMean->GetZaxis()->GetNbins() ? calibMean->GetZaxis()->GetNbins() : binEta); - - double mean = calibMean->GetBinContent(binTPCncls, binPin, binEta); - double width = calibSigma->GetBinContent(binTPCncls, binPin, binEta); + // compute TPC postcalibrated kaon nsigma if required if (!isTPCCalibrated) { - values[kTPCnSigmaKa_Corr] = (values[kTPCnSigmaKa] - mean) / width; + values[kTPCnSigmaKa_Corr] = ComputePIDcalibration(2, values[kTPCnSigmaKa]); } else { + LOG(fatal) << "TPC PID postcalibration is configured but the tracks are already postcalibrated. This is not allowed. Please check your configuration."; values[kTPCnSigmaKa_Corr] = track.tpcNSigmaKa(); } } // compute TPC postcalibrated proton nsigma if required if (fgUsedVars[kTPCnSigmaPr_Corr] && fgRunTPCPostCalibration[3]) { - TH3F* calibMean = reinterpret_cast(fgCalibs[kTPCProtonMean]); - TH3F* calibSigma = reinterpret_cast(fgCalibs[kTPCProtonSigma]); - - int binTPCncls = calibMean->GetXaxis()->FindBin(values[kTPCncls]); - binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); - binTPCncls = (binTPCncls > calibMean->GetXaxis()->GetNbins() ? calibMean->GetXaxis()->GetNbins() : binTPCncls); - int binPin = calibMean->GetYaxis()->FindBin(values[kPin]); - binPin = (binPin == 0 ? 1 : binPin); - binPin = (binPin > calibMean->GetYaxis()->GetNbins() ? calibMean->GetYaxis()->GetNbins() : binPin); - int binEta = calibMean->GetZaxis()->FindBin(values[kEta]); - binEta = (binEta == 0 ? 1 : binEta); - binEta = (binEta > calibMean->GetZaxis()->GetNbins() ? calibMean->GetZaxis()->GetNbins() : binEta); - - double mean = calibMean->GetBinContent(binTPCncls, binPin, binEta); - double width = calibSigma->GetBinContent(binTPCncls, binPin, binEta); if (!isTPCCalibrated) { - values[kTPCnSigmaPr_Corr] = (values[kTPCnSigmaPr] - mean) / width; + values[kTPCnSigmaPr_Corr] = ComputePIDcalibration(3, values[kTPCnSigmaPr]); } else { + LOG(fatal) << "TPC PID postcalibration is configured but the tracks are already postcalibrated. This is not allowed. Please check your configuration."; values[kTPCnSigmaPr_Corr] = track.tpcNSigmaPr(); } } diff --git a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx index 60670abfac6..c72742c3225 100644 --- a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx @@ -240,6 +240,8 @@ struct TableMaker { // TPC postcalibration related options struct : ConfigurableGroup { Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas(electrons, pions, protons)"}; + Configurable fConfigTPCpostCalibType{"cfgTPCpostCalibType", 1, "1: (TPCncls,pIN,eta) calibration typically for pp, 2: (eta,nPV,nLong,tLong) calibration typically for PbPb"}; + Configurable fConfigTPCuseInterpolatedCalib{"cfgTPCpostCalibUseInterpolation", true, "If true, use interpolated calibration values (default: true)"}; 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"}; @@ -1013,6 +1015,7 @@ struct TableMaker { (reinterpret_cast(fStatsList->At(kStatsTracks)))->Fill(fTrackCuts.size() + static_cast(iv0)); } } + // TODO: this part should be removed since the calibration histogram can be filled as any other histogram if (fConfigPostCalibTPC.fConfigIsOnlyforMaps) { if (trackFilteringTag & (static_cast(1) << VarManager::kIsConversionLeg)) { // for electron fHistMan->FillHistClass("TrackBarrel_PostCalibElectron", VarManager::fgValues); @@ -1305,6 +1308,15 @@ struct TableMaker { VarManager::SetCalibrationObject(VarManager::kTPCKaonMean, calibList->FindObject("mean_map_kaon")); VarManager::SetCalibrationObject(VarManager::kTPCKaonSigma, calibList->FindObject("sigma_map_kaon")); } + if (fConfigPostCalibTPC.fConfigTPCpostCalibType == 2) { + VarManager::SetCalibrationObject(VarManager::kTPCElectronStatus, calibList->FindObject("status_map_electron")); + VarManager::SetCalibrationObject(VarManager::kTPCPionStatus, calibList->FindObject("status_map_pion")); + VarManager::SetCalibrationObject(VarManager::kTPCProtonStatus, calibList->FindObject("status_map_proton")); + if (fConfigPostCalibTPC.fConfigComputeTPCpostCalibKaon) { + VarManager::SetCalibrationObject(VarManager::kTPCKaonStatus, calibList->FindObject("status_map_kaon")); + } + } + VarManager::SetCalibrationType(fConfigPostCalibTPC.fConfigTPCpostCalibType, fConfigPostCalibTPC.fConfigTPCuseInterpolatedCalib); } if (fIsRun2 == true) { fGrpMagRun2 = fCCDB->getForTimeStamp(fConfigCCDB.fConfigGrpMagPathRun2, bcs.begin().timestamp()); diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index ae6c450ac3e..3d3cd926b31 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -563,6 +563,8 @@ struct AnalysisTrackSelection { Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas"}; + Configurable fConfigTPCpostCalibType{"cfgTPCpostCalibType", 1, "1: (TPCncls,pIN,eta) calibration typically for pp, 2: (eta,nPV,nLong,tLong) calibration typically for PbPb"}; + Configurable fConfigTPCuseInterpolatedCalib{"cfgTPCpostCalibUseInterpolation", true, "If true, use interpolated calibration values (default: true)"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; // Track related options Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; @@ -648,6 +650,12 @@ struct AnalysisTrackSelection { 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 (fConfigTPCpostCalibType == 2) { + VarManager::SetCalibrationObject(VarManager::kTPCElectronStatus, calibList->FindObject("status_map_electron")); + VarManager::SetCalibrationObject(VarManager::kTPCPionStatus, calibList->FindObject("status_map_pion")); + VarManager::SetCalibrationObject(VarManager::kTPCProtonStatus, calibList->FindObject("status_map_proton")); + } + VarManager::SetCalibrationType(fConfigTPCpostCalibType, fConfigTPCuseInterpolatedCalib); } o2::parameters::GRPMagField* grpmag = fCCDB->getForTimeStamp(grpmagPath, events.begin().timestamp()); From c3ed2386905e5c7950c0e43b0209a0bfca7eb463 Mon Sep 17 00:00:00 2001 From: Ionut Cristian Arsene Date: Thu, 21 Aug 2025 18:15:02 +0200 Subject: [PATCH 4/5] fix a few compilation errors --- PWGDQ/Core/VarManager.cxx | 142 +++++++++++++++++++++++++++++++++++++ PWGDQ/Core/VarManager.h | 143 +------------------------------------- 2 files changed, 145 insertions(+), 140 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index e2a138dec89..ce8315d1148 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -211,6 +211,148 @@ float VarManager::calculateCosPA(KFParticle kfp, KFParticle PV) { return cpaFromKF(kfp, PV); } + +//__________________________________________________________________ +double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { + // species: 0 - electron, 1 - pion, 2 - kaon, 3 - proton + // Depending on the PID calibration type, we use different types of calibration histograms + + if (fgCalibrationType == 1) { + // get the calibration histograms + CalibObjects calibMean, calibSigma; + switch (species) { + case 0: + calibMean = kTPCElectronMean; + calibSigma = kTPCElectronSigma; + break; + case 1: + calibMean = kTPCPionMean; + calibSigma = kTPCPionSigma; + break; + case 2: + calibMean = kTPCKaonMean; + calibSigma = kTPCKaonSigma; + break; + case 3: + calibMean = kTPCProtonMean; + calibSigma = kTPCProtonSigma; + break; + default: + LOG(fatal) << "Invalid species for PID calibration: " << species; + return -999.0; // Return zero if species is invalid + }; + + TH3F* calibMeanHist = reinterpret_cast(fgCalibs[calibMean]); + TH3F* calibSigmaHist = reinterpret_cast(fgCalibs[calibSigma]); + if (!calibMeanHist || !calibSigmaHist) { + LOG(fatal) << "Calibration histograms not found for species: " << species; + return -999.0; // Return zero if histograms are not found + } + + // Get the bin indices for the calibration histograms + int binTPCncls = calibMeanHist->GetXaxis()->FindBin(fgValues[kTPCncls]); + binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); + binTPCncls = (binTPCncls > calibMeanHist->GetXaxis()->GetNbins() ? calibMeanHist->GetXaxis()->GetNbins() : binTPCncls); + int binPin = calibMeanHist->GetYaxis()->FindBin(fgValues[kPin]); + binPin = (binPin == 0 ? 1 : binPin); + binPin = (binPin > calibMeanHist->GetYaxis()->GetNbins() ? calibMeanHist->GetYaxis()->GetNbins() : binPin); + int binEta = calibMeanHist->GetZaxis()->FindBin(fgValues[kEta]); + binEta = (binEta == 0 ? 1 : binEta); + binEta = (binEta > calibMeanHist->GetZaxis()->GetNbins() ? calibMeanHist->GetZaxis()->GetNbins() : binEta); + + double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta); + double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta); + return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value + } + else if (fgCalibrationType == 2) { + // get the calibration histograms + CalibObjects calibMean, calibSigma, calibStatus; + switch (species) { + case 0: + calibMean = kTPCElectronMean; + calibSigma = kTPCElectronSigma; + calibStatus = kTPCElectronStatus; + break; + case 1: + calibMean = kTPCPionMean; + calibSigma = kTPCPionSigma; + calibStatus = kTPCPionStatus; + break; + case 2: + calibMean = kTPCKaonMean; + calibSigma = kTPCKaonSigma; + calibStatus = kTPCKaonStatus; + break; + case 3: + calibMean = kTPCProtonMean; + calibSigma = kTPCProtonSigma; + calibStatus = kTPCProtonStatus; + break; + default: + LOG(fatal) << "Invalid species for PID calibration: " << species; + return -999.0; // Return zero if species is invalid + }; + + THnF* calibMeanHist = reinterpret_cast(fgCalibs[calibMean]); + THnF* calibSigmaHist = reinterpret_cast(fgCalibs[calibSigma]); + THnF* calibStatusHist = reinterpret_cast(fgCalibs[calibStatus]); + if (!calibMeanHist || !calibSigmaHist || !calibStatusHist) { + LOG(fatal) << "Calibration histograms not found for species: " << species; + return -999.0; // Return zero if histograms are not found + } + + // Get the bin indices for the calibration histograms + int binEta = calibMeanHist->GetAxis(0)->FindBin(fgValues[kEta]); + binEta = (binEta == 0 ? 1 : binEta); + binEta = (binEta > calibMeanHist->GetAxis(0)->GetNbins() ? calibMeanHist->GetAxis(0)->GetNbins() : binEta); + int binNpv = calibMeanHist->GetAxis(1)->FindBin(fgValues[kVtxNcontribReal]); + binNpv = (binNpv == 0 ? 1 : binNpv); + binNpv = (binNpv > calibMeanHist->GetAxis(1)->GetNbins() ? calibMeanHist->GetAxis(1)->GetNbins() : binNpv); + int binNlong = calibMeanHist->GetAxis(2)->FindBin(fgValues[kNTPCcontribLongA]); + binNlong = (binNlong == 0 ? 1 : binNlong); + binNlong = (binNlong > calibMeanHist->GetAxis(2)->GetNbins() ? calibMeanHist->GetAxis(2)->GetNbins() : binNlong); + int binTlong = calibMeanHist->GetAxis(3)->FindBin(fgValues[kNTPCmedianTimeLongA]); + binTlong = (binTlong == 0 ? 1 : binTlong); + binTlong = (binTlong > calibMeanHist->GetAxis(3)->GetNbins() ? calibMeanHist->GetAxis(3)->GetNbins() : binTlong); + + int bin[4] = {binEta, binNpv, binNlong, binTlong}; + int status = static_cast(calibStatusHist->GetBinContent(bin)); + double mean = calibMeanHist->GetBinContent(bin); + double sigma = calibSigmaHist->GetBinContent(bin); + switch (status) { + case 0: + // good calibration, return the calibrated nSigma value + return (nSigmaValue - mean) / sigma; + break; + case 1: + // calibration not valid, return the original nSigma value + return nSigmaValue; + break; + case 2: // calibration constant has poor stat uncertainty, consider the user option for what to do + case 3: + // calibration constants have been interpolated + if (fgUseInterpolatedCalibration) { + return (nSigmaValue - mean) / sigma; + } else { + // return the original nSigma value + return nSigmaValue; + } + break; + case 4: + // calibration constants interpolation failed, return the original nSigma value + return nSigmaValue; + break; + default: + return nSigmaValue; // unknown status, return the original nSigma value + break; + }; + } else { + // unknown calibration type, return the original nSigma value + LOG(fatal) << "Unknown calibration type: " << fgCalibrationType; + return nSigmaValue; // Return the original nSigma value + } +} + //__________________________________________________________________ void VarManager::SetDefaultVarNames() { diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index e48a8aa0ca9..5297ea564f9 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -50,6 +50,7 @@ #include "Math/VectorUtil.h" #include "TGeoGlobalMagField.h" #include "TH3F.h" +#include "THn.h" #include "TRandom.h" #include #include @@ -1156,11 +1157,12 @@ class VarManager : public TObject static void SetCalibrationType(int type, bool useInterpolation = true) { if (type < 0 || type > 2) { - LOG(fatal) << "Invalid calibration type. Must be 0, 1, or 2."); + LOG(fatal) << "Invalid calibration type. Must be 0, 1, or 2."; } fgCalibrationType = type; fgUseInterpolatedCalibration = useInterpolation; } + static double ComputePIDcalibration(int species, double nSigmaValue); static TObject* GetCalibrationObject(CalibObjects calib) { @@ -1378,145 +1380,6 @@ o2::dataformats::GlobalFwdTrack VarManager::PropagateMuon(const T& muon, const C return propmuon; } -double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { - // species: 0 - electron, 1 - pion, 2 - kaon, 3 - proton - // Depending on the PID calibration type, we use different types of calibration histograms - - if (fgCalibrationType == 1) { - // get the calibration histograms - CalibObjects calibMean, calibSigma; - switch (species) { - case 0: - calibMean = kTPCElectronMean; - calibSigma = kTPCElectronSigma; - break; - case 1: - calibMean = kTPCPionMean; - calibSigma = kTPCPionSigma; - break; - case 2: - calibMean = kTPCKaonMean; - calibSigma = kTPCKaonSigma; - break; - case 3: - calibMean = kTPCProtonMean; - calibSigma = kTPCProtonSigma; - break; - default: - LOG(fatal) << "Invalid species for PID calibration: " << species; - return -999.0; // Return zero if species is invalid - }; - - TH3F* calibMeanHist = reinterpret_cast(fgCalibs[calibMean]); - TH3F* calibSigmaHist = reinterpret_cast(fgCalibs[calibSigma]); - if (!calibMeanHist || !calibSigmaHist) { - LOG(fatal) << "Calibration histograms not found for species: " << species; - return -999.0; // Return zero if histograms are not found - } - - // Get the bin indices for the calibration histograms - int binTPCncls = calibMeanHist->GetXaxis()->FindBin(fgValues[kTPCncls]); - binTPCncls = (binTPCncls == 0 ? 1 : binTPCncls); - binTPCncls = (binTPCncls > calibMeanHist->GetXaxis()->GetNbins() ? calibMeanHist->GetXaxis()->GetNbins() : binTPCncls); - int binPin = calibMeanHist->GetYaxis()->FindBin(fgValues[kPin]); - binPin = (binPin == 0 ? 1 : binPin); - binPin = (binPin > calibMeanHist->GetYaxis()->GetNbins() ? calibMeanHist->GetYaxis()->GetNbins() : binPin); - int binEta = calibMeanHist->GetZaxis()->FindBin(fgValues[kEta]); - binEta = (binEta == 0 ? 1 : binEta); - binEta = (binEta > calibMeanHist->GetZaxis()->GetNbins() ? calibMeanHist->GetZaxis()->GetNbins() : binEta); - - double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta); - double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta); - return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value - } - else if (fgCalibrationType == 2) { - // get the calibration histograms - CalibObjects calibMean, calibSigma, calibStatus; - switch (species) { - case 0: - calibMean = kTPCElectronMean; - calibSigma = kTPCElectronSigma; - calibStatus = kTPCElectronStatus; - break; - case 1: - calibMean = kTPCPionMean; - calibSigma = kTPCPionSigma; - calibStatus = kTPCPionStatus; - break; - case 2: - calibMean = kTPCKaonMean; - calibSigma = kTPCKaonSigma; - calibStatus = kTPCKaonStatus; - break; - case 3: - calibMean = kTPCProtonMean; - calibSigma = kTPCProtonSigma; - calibStatus = kTPCProtonStatus; - break; - default: - LOG(fatal) << "Invalid species for PID calibration: " << species; - return -999.0; // Return zero if species is invalid - }; - - THnF* calibMeanHist = reinterpret_cast(fgCalibs[calibMean]); - THnF* calibSigmaHist = reinterpret_cast(fgCalibs[calibSigma]); - THnF* calibStatusHist = reinterpret_cast(fgCalibs[calibStatus]); - if (!calibMeanHist || !calibSigmaHist || !calibStatusHist) { - LOG(fatal) << "Calibration histograms not found for species: " << species; - return -999.0; // Return zero if histograms are not found - } - - // Get the bin indices for the calibration histograms - int binEta = calibMeanHist->GetAxis(0)->FindBin(fgValues[kEta]); - binEta = (binEta == 0 ? 1 : binEta); - binEta = (binEta > calibMeanHist->GetAxis(0)->GetNbins() ? calibMeanHist->GetAxis(0)->GetNbins() : binEta); - int binNpv = calibMeanHist->GetAxis(1)->FindBin(fgValues[kVtxNcontribReal]); - binNpv = (binNpv == 0 ? 1 : binNpv); - binNpv = (binNpv > calibMeanHist->GetAxis(1)->GetNbins() ? calibMeanHist->GetAxis(1)->GetNbins() : binNpv); - int binNlong = calibMeanHist->GetAxis(2)->FindBin(fgValues[kNTPCcontribLongA]); - binNlong = (binNlong == 0 ? 1 : binNlong); - binNlong = (binNlong > calibMeanHist->GetAxis(2)->GetNbins() ? calibMeanHist->GetAxis(2)->GetNbins() : binNlong); - int binTlong = calibMeanHist->GetAxis(3)->FindBin(fgValues[kNTPCmedianTimeLongA]); - binTlong = (binTlong == 0 ? 1 : binTlong); - binTlong = (binTlong > calibMeanHist->GetAxis(3)->GetNbins() ? calibMeanHist->GetAxis(3)->GetNbins() : binTlong); - - int bin[4] = {binEta, binNpv, binNlong, binTlong}; - int status = reinterpret_cast(calibStatusHist->GetBinContent(bin)); - double mean = calibMeanHist->GetBinContent(bin); - double sigma = calibSigmaHist->GetBinContent(bin); - switch (status) { - case 0: - // good calibration, return the calibrated nSigma value - return (nSigmaValue - mean) / sigma; - break; - case 1: - // calibration not valid, return the original nSigma value - return nSigmaValue; - break; - case 2: // calibration constant has poor stat uncertainty, consider the user option for what to do - case 3: - // calibration constants have been interpolated - if (fgUseInterpolatedCalibration) { - return (nSigmaValue - mean) / sigma; - } else { - // return the original nSigma value - return nSigmaValue; - } - break; - case 4: - // calibration constants interpolation failed, return the original nSigma value - return nSigmaValue; - break; - default: - return nSigmaValue; // unknown status, return the original nSigma value - break; - }; - } else { - // unknown calibration type, return the original nSigma value - LOG(fatal) << "Unknown calibration type: " << fgCalibrationType; - return nSigmaValue; // Return the original nSigma value - } -} template void VarManager::FillMuonPDca(const T& muon, const C& collision, float* values) From 4e1b5122ec12fc9871105e50f472085f097b34e7 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Thu, 21 Aug 2025 16:27:44 +0000 Subject: [PATCH 5/5] Please consider the following formatting changes --- PWGDQ/Core/VarManager.cxx | 20 ++++++++++---------- PWGDQ/Core/VarManager.h | 7 +++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index ce8315d1148..eb263b73373 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -45,7 +45,7 @@ o2::vertexing::FwdDCAFitterN<3> VarManager::fgFitterThreeProngFwd; o2::globaltracking::MatchGlobalFwd VarManager::mMatching; std::map VarManager::fgCalibs; bool VarManager::fgRunTPCPostCalibration[4] = {false, false, false, false}; -int VarManager::fgCalibrationType = 0; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb +int VarManager::fgCalibrationType = 0; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb bool VarManager::fgUseInterpolatedCalibration = true; // use interpolated calibration histograms (default: true) //__________________________________________________________________ @@ -213,7 +213,8 @@ float VarManager::calculateCosPA(KFParticle kfp, KFParticle PV) } //__________________________________________________________________ -double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { +double VarManager::ComputePIDcalibration(int species, double nSigmaValue) +{ // species: 0 - electron, 1 - pion, 2 - kaon, 3 - proton // Depending on the PID calibration type, we use different types of calibration histograms @@ -263,8 +264,7 @@ double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta); double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta); return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value - } - else if (fgCalibrationType == 2) { + } else if (fgCalibrationType == 2) { // get the calibration histograms CalibObjects calibMean, calibSigma, calibStatus; switch (species) { @@ -323,12 +323,12 @@ double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { case 0: // good calibration, return the calibrated nSigma value return (nSigmaValue - mean) / sigma; - break; + break; case 1: // calibration not valid, return the original nSigma value return nSigmaValue; - break; - case 2: // calibration constant has poor stat uncertainty, consider the user option for what to do + break; + case 2: // calibration constant has poor stat uncertainty, consider the user option for what to do case 3: // calibration constants have been interpolated if (fgUseInterpolatedCalibration) { @@ -337,14 +337,14 @@ double VarManager::ComputePIDcalibration(int species, double nSigmaValue) { // return the original nSigma value return nSigmaValue; } - break; + break; case 4: // calibration constants interpolation failed, return the original nSigma value return nSigmaValue; - break; + break; default: return nSigmaValue; // unknown status, return the original nSigma value - break; + break; }; } else { // unknown calibration type, return the original nSigma value diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 5297ea564f9..230a899d807 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -1239,8 +1239,8 @@ class VarManager : public TObject static std::map fgCalibs; // map of calibration histograms static bool fgRunTPCPostCalibration[4]; // 0-electron, 1-pion, 2-kaon, 3-proton - static int fgCalibrationType; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb - static bool fgUseInterpolatedCalibration; // use interpolated calibration histograms (default: true) + static int fgCalibrationType; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb + static bool fgUseInterpolatedCalibration; // use interpolated calibration histograms (default: true) VarManager& operator=(const VarManager& c); VarManager(const VarManager& c); @@ -1380,7 +1380,6 @@ o2::dataformats::GlobalFwdTrack VarManager::PropagateMuon(const T& muon, const C return propmuon; } - template void VarManager::FillMuonPDca(const T& muon, const C& collision, float* values) { @@ -2480,7 +2479,7 @@ void VarManager::FillTrack(T const& track, float* values) values[kTPCnSigmaPr_Corr] = track.tpcNSigmaPr(); } } - + if constexpr ((fillMap & TrackPID) > 0 || (fillMap & ReducedTrackBarrelPID) > 0) { values[kTOFnSigmaEl] = track.tofNSigmaEl(); values[kTOFnSigmaPi] = track.tofNSigmaPi();