206 return m_histo->GetBinContent(std::as_const(*m_histo).GetXaxis()->FindFixBin(valX));
233 return m_histo->GetBinContent(std::as_const(*m_histo).GetXaxis()->FindFixBin(valX),
234 std::as_const(*m_histo).GetYaxis()->FindFixBin(valY));
259 return m_histo->GetBinContent(std::as_const(*m_histo).GetXaxis()->FindFixBin(valX),
260 std::as_const(*m_histo).GetYaxis()->FindFixBin(valY),
261 std::as_const(*m_histo).GetZaxis()->FindFixBin(valZ));
295 const static int maxNumWarn = 0;
296 static std::atomic<int> numWarn = 0;
302 float val = valInput;
303 const double lowVal = axis->GetBinLowEdge(1);
304 const double highVal = axis->GetBinLowEdge(numBins+1);
305 if (val < lowVal || val >= highVal)
307 if (val != highVal && ++numWarn < maxNumWarn)
308 ATH_MSG_WARNING(Form(
"Variable value is %f, outside of the axis range of (%f,%f) for %s. "
309 "Using closest valid value.",val,lowVal,highVal,
getName().
Data())
310 <<
" (Only first " << maxNumWarn <<
" instances printed, this is " << numWarn <<
")");
314 val = lowVal>0 ? (1.0+1.e-4)*lowVal : (1.0-1.e-4)*lowVal;
316 val = highVal>0 ? (1.0-1.e-4)*highVal : (1.0+1.e-4)*highVal;
328 return StatusCode::FAILURE;
334 ATH_MSG_FATAL(
"Unsupported histogram dimensionality for projection caching: " <<
m_histo->GetDimension());
335 return StatusCode::FAILURE;
342 return StatusCode::FAILURE;
350 if (
m_histo->GetDimension() == 1)
351 return StatusCode::SUCCESS;
356 if (
m_histo->GetDimension() == 1)
359 return StatusCode::FAILURE;
365 return StatusCode::FAILURE;
373 if (
m_histo->GetDimension() == 2)
376 TH2* localHist =
dynamic_cast<TH2*
>(
m_histo);
380 ATH_MSG_FATAL(
"Failed to convert histogram to a TH2, please check inputs: " <<
m_name.Data());
381 return StatusCode::FAILURE;
387 for (Long64_t binY = 0; binY < localHist->GetNbinsY()+1; ++binY)
390 m_cachedProj.at(0).emplace_back(localHist->ProjectionX(Form(
"projx_%lld",binY),binY,binY));
395 for (Long64_t binX = 0; binX < localHist->GetNbinsX()+1; ++binX)
398 m_cachedProj.at(0).emplace_back(localHist->ProjectionY(Form(
"projy_%lld",binX),binX,binX));
404 ATH_MSG_FATAL(
"Unexpected interpolation type, somehow escaped earlier checks: " <<
m_name.Data());
405 return StatusCode::FAILURE;
408 else if (
m_histo->GetDimension() == 3)
411 TH3* localHist =
dynamic_cast<TH3*
>(
m_histo);
414 ATH_MSG_FATAL(
"Failed to convert histogram to a TH3, please check inputs: " <<
m_name.Data());
415 return StatusCode::FAILURE;
422 for (Long64_t binY = 0; binY < localHist->GetNbinsY()+1; ++binY)
424 for (Long64_t binZ = 0; binZ < localHist->GetNbinsZ()+1; ++binZ)
427 m_cachedProj.at(binY).emplace_back(localHist->ProjectionX(Form(
"projx_%lld_%lld",binY,binZ),binY,binY,binZ,binZ));
434 for (Long64_t binX = 0; binX < localHist->GetNbinsX()+1; ++binX)
436 for (Long64_t binZ = 0; binZ < localHist->GetNbinsZ()+1; ++binZ)
439 m_cachedProj.at(binX).emplace_back(localHist->ProjectionY(Form(
"projy_%lld_%lld",binX,binZ),binX,binX,binZ,binZ));
446 ATH_MSG_FATAL(
"Unexpected interpolation type, somehow escaped earlier checks: " <<
m_name.Data());
447 return StatusCode::FAILURE;
454 return StatusCode::FAILURE;
462 hist->SetDirectory(
nullptr);
467 return StatusCode::SUCCESS;