Collapsing two Profile1D's into one Scatter2D
I sometimes need to perform this operation. Standard use case is that two quantities are measured in terms of one observable, and afterwards correlated in an analysis, and it is only the latter which is presented in HepData. I cannot simply bin in the correlated observable, since the initial binning in two observables introduces biases. I must therefore use something like this:
// Collapse the vertical axes of two profiles into a
// single Scatter2D, with the first profile being
// the horizontal axis of the scatter, and the second
// being the vertical. It is assumed that the input
// scatters are binned in the same quantity, and their
// horizontal axis binning must be identical.
bool collapseX(Scatter2DPtr resPtr, Profile1DPtr xProfPtr,
Profile1DPtr yProfPtr) {
// Get the bins of input profiles.
vector<YODA::ProfileBin1D>& binX = xProfPtr->bins();
vector<YODA::ProfileBin1D>& binY = yProfPtr->bins();
// Test that the x-axes on the two input profiles are identical.
if (binX.size() != binY.size()) return false;
for (size_t i = 0; i < binX.size(); ++i)
if (binX[i].xMin() != binY[i].xMin() ||
binX[i].xMax() != binY[i].xMax()) return false;
// Make the resulting scatter.
resPtr->reset();
for (size_t i = 0; i < binX.size(); ++i)
resPtr->addPoint(binX[i].mean(), binY[i].mean(), binX[i].stdErr(),
binY[i].stdErr());
return true;
}
It is frequent enough that I would like it to be a method of the Analysis
base class, but since it is abusing data types a bit, I wanted to bring up the discussion first. I suspect that at least @20DM and @agbuckley - maybe also @lcorpe - would have opinions. Maybe it is already possible to do in a method unknown to me?
Edited by Christian Bierlich