// The input data and covariance matrix include bins for CC0pi0p, CC0pi1p, and CC0piNp. We may not want them all if we only want to look at one or two of the sub-samples, so go through and only keep the bins we want
// CC0pi0p: bins 1-60 -> 60 bins
// CC0pi1p: bins 61-92 -> 32 bins
// CC0piNp: bin 93 -> 1 bin
int n_binskeep = 0;
if (useCC0pi0p) n_binskeep += 60;
if (useCC0pi1p) n_binskeep += 32;
if (useCC0piNp) n_binskeep += 1;
fDataHist = new TH1D("DataHist", tempDataHist->GetTitle(),n_binskeep,0,n_binskeep);
fFullCovar = new TMatrixDSym(n_binskeep);
int i_binskeep = 1;
for (int i_allbins=1; i_allbins<tempDataHist->GetNbinsX()+1; i_allbins++){
if ((i_allbins >=1 && i_allbins <=60) && !useCC0pi0p) continue;
if ((i_allbins >= 61 && i_allbins <=92) && !useCC0pi1p) continue;
// The code below converts a relative covariance matrix to an absolute one. I think the input is absolute so we don't need it, but come back to this if the results look weird
// for (int i = 0; i < fDataHist->GetNbinsX(); i++) {
// If you're looking at a sample you don't want to look at, return -999
if (nProtonsAboveThresh == 0 && !useCC0pi0p){return binnumber;}
if (nProtonsAboveThresh == 1 && !useCC0pi1p){return binnumber;}
if (nProtonsAboveThresh >= 2 && !useCC0piNp){return binnumber;}
// Calculate bin number (check that we want to use this sample before looking for the correct bin to save computation -- probably redundant because of the checks above but I like to be careful)
if (nProtonsAboveThresh == 0 && useCC0pi0p){ //CC0pi0p: 2D binning in CosThetaMu--pmu
// No check on binnumber = -999 here, because many events won't fall into one of these slices
// If useCC0pi0p is false, adjust slice numbers for CC0pi1p
if (useCC0pi1p && !useCC0pi0p){
slicenumber -= 10;
}
return slicenumber;
};
// // Reimplementation of Measurement1D::Write (calling the original) to also set the slice histograms to have the chi2 of the total 1D histogram -- makes plotting easier