diff --git a/CIValidations/BinningValidations.cpp b/CIValidations/BinningValidations.cpp index c3bbc56..47fd7e0 100755 --- a/CIValidations/BinningValidations.cpp +++ b/CIValidations/BinningValidations.cpp @@ -33,7 +33,27 @@ XVarBins: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1] for (double xvar : XVars) { for (int nomXBin : NomXBins) { for (int nomYBin : NomYBins) { - const int GlobalBin = Binning->FindGlobalBin(sample, xvar, nomXBin, nomYBin); + std::vector KinVar; + std::vector NomBin; + + if(sample == 0){ + double yvar = 0; + switch(nomYBin){ + case 0: yvar = 0.05; break; + case 1: yvar = 0.15; break; + case 2: yvar = 0.25; break; + case 3: yvar = 0.35; break; + default: yvar = 0; break; + } + + KinVar = {&xvar, &yvar}; + NomBin = {nomXBin, nomYBin}; + } else if (sample == 1){ + KinVar = {&xvar}; + NomBin = {nomXBin}; + } + + const int GlobalBin = Binning->FindGlobalBin(sample, KinVar, NomBin); outFile << "Sample " << sample << ", XVar: " << xvar << ", NomXBin: " << nomXBin @@ -60,12 +80,15 @@ int main(int argc, char *argv[]) std::ofstream outFile("NewBinningOut.txt"); auto Binning = std::make_unique(); - Binning->XBinEdges = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}; - Binning->YBinEdges = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}; - Binning->nXBins = Binning->XBinEdges.size() - 1; - Binning->nYBins = Binning->YBinEdges.size() - 1; - Binning->nBins = Binning->nXBins * Binning->nYBins; - Binning->InitialiseBinMigrationLookUp(); + constexpr int dim = 2; + Binning->BinEdges.resize(dim); + Binning->BinEdges[0] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}; + Binning->BinEdges[1] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}; + Binning->AxisNBins.resize(dim); + Binning->AxisNBins[0] = Binning->BinEdges[0].size() - 1; + Binning->AxisNBins[1] = Binning->BinEdges[1].size() - 1; + Binning->nBins = Binning->AxisNBins[0] * Binning->AxisNBins[1]; + Binning->InitialiseBinMigrationLookUp(dim); std::vector> testPairs = { {-1.0, -1}, @@ -101,12 +124,13 @@ int main(int argc, char *argv[]) }; for (const auto& [XVar, NomXBin] : testPairs) { - int binIndex = Binning->FindXBin(XVar, NomXBin); + constexpr int dim = 0; // XVar is dimension 0 + int binIndex = Binning->FindBin(dim, XVar, NomXBin); outFile << "XVar: " << XVar << ", NomXBin: " << NomXBin << ", Bin: " << binIndex << std::endl; } - for (size_t yBin = 0; yBin < Binning->nYBins; ++yBin) { - for (size_t xBin = 0; xBin < Binning->nXBins; ++xBin) { + for (size_t yBin = 0; yBin < Binning->AxisNBins[1]; ++yBin) { + for (size_t xBin = 0; xBin < Binning->AxisNBins[0]; ++xBin) { const int binIndex = Binning->GetBinSafe(xBin, yBin); outFile << "yBin: " << yBin << ", xBin: " << xBin << ", Bin: " << binIndex << std::endl; diff --git a/CIValidations/TestOutputs/BinningOut.txt b/CIValidations/TestOutputs/BinningOut.txt index 4e71e7d..04f65bf 100644 --- a/CIValidations/TestOutputs/BinningOut.txt +++ b/CIValidations/TestOutputs/BinningOut.txt @@ -237,53 +237,53 @@ Sample 1, XVar: -1, NomXBin: 3, NomYBin: 1, GlobalBin: -1 Sample 1, XVar: -1, NomXBin: 3, NomYBin: 2, GlobalBin: -1 Sample 1, XVar: -1, NomXBin: 3, NomYBin: 3, GlobalBin: -1 Sample 1, XVar: 0, NomXBin: 0, NomYBin: 0, GlobalBin: 100 -Sample 1, XVar: 0, NomXBin: 0, NomYBin: 1, GlobalBin: 110 -Sample 1, XVar: 0, NomXBin: 0, NomYBin: 2, GlobalBin: 120 -Sample 1, XVar: 0, NomXBin: 0, NomYBin: 3, GlobalBin: 130 +Sample 1, XVar: 0, NomXBin: 0, NomYBin: 1, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 0, NomYBin: 2, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 0, NomYBin: 3, GlobalBin: 100 Sample 1, XVar: 0, NomXBin: 1, NomYBin: 0, GlobalBin: 100 -Sample 1, XVar: 0, NomXBin: 1, NomYBin: 1, GlobalBin: 110 -Sample 1, XVar: 0, NomXBin: 1, NomYBin: 2, GlobalBin: 120 -Sample 1, XVar: 0, NomXBin: 1, NomYBin: 3, GlobalBin: 130 +Sample 1, XVar: 0, NomXBin: 1, NomYBin: 1, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 1, NomYBin: 2, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 1, NomYBin: 3, GlobalBin: 100 Sample 1, XVar: 0, NomXBin: 2, NomYBin: 0, GlobalBin: 100 -Sample 1, XVar: 0, NomXBin: 2, NomYBin: 1, GlobalBin: 110 -Sample 1, XVar: 0, NomXBin: 2, NomYBin: 2, GlobalBin: 120 -Sample 1, XVar: 0, NomXBin: 2, NomYBin: 3, GlobalBin: 130 +Sample 1, XVar: 0, NomXBin: 2, NomYBin: 1, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 2, NomYBin: 2, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 2, NomYBin: 3, GlobalBin: 100 Sample 1, XVar: 0, NomXBin: 3, NomYBin: 0, GlobalBin: 100 -Sample 1, XVar: 0, NomXBin: 3, NomYBin: 1, GlobalBin: 110 -Sample 1, XVar: 0, NomXBin: 3, NomYBin: 2, GlobalBin: 120 -Sample 1, XVar: 0, NomXBin: 3, NomYBin: 3, GlobalBin: 130 +Sample 1, XVar: 0, NomXBin: 3, NomYBin: 1, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 3, NomYBin: 2, GlobalBin: 100 +Sample 1, XVar: 0, NomXBin: 3, NomYBin: 3, GlobalBin: 100 Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 0, GlobalBin: 105 -Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 1, GlobalBin: 115 -Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 2, GlobalBin: 125 -Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 3, GlobalBin: 135 +Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 1, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 2, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 0, NomYBin: 3, GlobalBin: 105 Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 0, GlobalBin: 105 -Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 1, GlobalBin: 115 -Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 2, GlobalBin: 125 -Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 3, GlobalBin: 135 +Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 1, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 2, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 1, NomYBin: 3, GlobalBin: 105 Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 0, GlobalBin: 105 -Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 1, GlobalBin: 115 -Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 2, GlobalBin: 125 -Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 3, GlobalBin: 135 +Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 1, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 2, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 2, NomYBin: 3, GlobalBin: 105 Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 0, GlobalBin: 105 -Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 1, GlobalBin: 115 -Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 2, GlobalBin: 125 -Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 3, GlobalBin: 135 +Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 1, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 2, GlobalBin: 105 +Sample 1, XVar: 0.5, NomXBin: 3, NomYBin: 3, GlobalBin: 105 Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 0, GlobalBin: 107 -Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 1, GlobalBin: 117 -Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 2, GlobalBin: 127 -Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 3, GlobalBin: 137 +Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 1, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 2, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 0, NomYBin: 3, GlobalBin: 107 Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 0, GlobalBin: 107 -Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 1, GlobalBin: 117 -Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 2, GlobalBin: 127 -Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 3, GlobalBin: 137 +Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 1, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 2, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 1, NomYBin: 3, GlobalBin: 107 Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 0, GlobalBin: 107 -Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 1, GlobalBin: 117 -Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 2, GlobalBin: 127 -Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 3, GlobalBin: 137 +Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 1, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 2, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 2, NomYBin: 3, GlobalBin: 107 Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 0, GlobalBin: 107 -Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 1, GlobalBin: 117 -Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 2, GlobalBin: 127 -Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 3, GlobalBin: 137 +Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 1, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 2, GlobalBin: 107 +Sample 1, XVar: 0.7, NomXBin: 3, NomYBin: 3, GlobalBin: 107 Sample 1, XVar: 1, NomXBin: 0, NomYBin: 0, GlobalBin: -1 Sample 1, XVar: 1, NomXBin: 0, NomYBin: 1, GlobalBin: -1 Sample 1, XVar: 1, NomXBin: 0, NomYBin: 2, GlobalBin: -1 diff --git a/CIValidations/TestOutputs/SampleOut.txt b/CIValidations/TestOutputs/SampleOut.txt index 0abbed6..3163583 100644 --- a/CIValidations/TestOutputs/SampleOut.txt +++ b/CIValidations/TestOutputs/SampleOut.txt @@ -410177,26 +410177,26 @@ Info for sample: ND_CC0pi Rates Prior: 20125.192000 Likelihood: 0.000000 Rates Post:20125.192000 -Likelihood:17190.607414 +Likelihood:17141.481720 Info for sample: ND_CC1pip -Rates Prior: 7070.364475 +Rates Prior: 7067.803433 Likelihood: 0.000000 -Rates Post:7070.364475 -Likelihood:10120.242940 +Rates Post:7067.803433 +Likelihood:10073.678286 Info for sample: ND_CCPi0 -Rates Prior: 2406.078134 +Rates Prior: 2384.678286 Likelihood: 0.000000 -Rates Post:2406.078134 -Likelihood:7714.164805 +Rates Post:2384.678286 +Likelihood:7689.000000 Info for sample: ND_NC0pi -Rates Prior: 6231.164805 +Rates Prior: 6220.000000 Likelihood: 0.000000 -Rates Post:6231.164805 -Likelihood:1483.000000 +Rates Post:6220.000000 +Likelihood:1469.000000 Info for sample: ND_NC1pi0 -Rates Prior: 1483.000000 +Rates Prior: 1469.000000 Likelihood: 0.000000 -Rates Post:1483.000000 +Rates Post:1469.000000 Likelihood:0.000000 Sample: ND2137 Event: 0 weight: 0.000000 Sample: ND2137 Event: 1 weight: 0.655575 @@ -443916,7 +443916,7 @@ Contents of Rates_Debug_ND_CC0pi.txt: Sample: ND_CC1pip update w2: true LLH is: 0.000000 using: Poisson test stat Sample: ND_CC1pip update w2: true LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_CC1pip update w2: true LLH is: 325.823261 using: IceCube test stat +Sample: ND_CC1pip update w2: true LLH is: 325.808040 using: IceCube test stat Sample: ND_CC1pip update w2: true LLH is: 0.000000 using: Pearson test stat Sample: ND_CC1pip update w2: true LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_CC1pip.txt: @@ -443942,7 +443942,7 @@ Contents of Rates_Debug_ND_CC1pip.txt: Sample: ND_CCPi0 update w2: true LLH is: 0.000000 using: Poisson test stat Sample: ND_CCPi0 update w2: true LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_CCPi0 update w2: true LLH is: 272.910885 using: IceCube test stat +Sample: ND_CCPi0 update w2: true LLH is: 272.610039 using: IceCube test stat Sample: ND_CCPi0 update w2: true LLH is: 0.000000 using: Pearson test stat Sample: ND_CCPi0 update w2: true LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_CCPi0.txt: @@ -443968,7 +443968,7 @@ Contents of Rates_Debug_ND_CCPi0.txt: Sample: ND_NC0pi update w2: true LLH is: 0.000000 using: Poisson test stat Sample: ND_NC0pi update w2: true LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_NC0pi update w2: true LLH is: 144.116287 using: IceCube test stat +Sample: ND_NC0pi update w2: true LLH is: 143.696831 using: IceCube test stat Sample: ND_NC0pi update w2: true LLH is: 0.000000 using: Pearson test stat Sample: ND_NC0pi update w2: true LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_NC0pi.txt: @@ -443994,7 +443994,7 @@ Contents of Rates_Debug_ND_NC0pi.txt: Sample: ND_NC1pi0 update w2: true LLH is: 0.000000 using: Poisson test stat Sample: ND_NC1pi0 update w2: true LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_NC1pi0 update w2: true LLH is: 55.386077 using: IceCube test stat +Sample: ND_NC1pi0 update w2: true LLH is: 55.199269 using: IceCube test stat Sample: ND_NC1pi0 update w2: true LLH is: 0.000000 using: Pearson test stat Sample: ND_NC1pi0 update w2: true LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_NC1pi0.txt: @@ -444046,7 +444046,7 @@ Contents of Rates_Debug_ND_CC0pi.txt: Sample: ND_CC1pip update w2: false LLH is: 0.000000 using: Poisson test stat Sample: ND_CC1pip update w2: false LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_CC1pip update w2: false LLH is: 325.823261 using: IceCube test stat +Sample: ND_CC1pip update w2: false LLH is: 325.808040 using: IceCube test stat Sample: ND_CC1pip update w2: false LLH is: 0.000000 using: Pearson test stat Sample: ND_CC1pip update w2: false LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_CC1pip.txt: @@ -444072,7 +444072,7 @@ Contents of Rates_Debug_ND_CC1pip.txt: Sample: ND_CCPi0 update w2: false LLH is: 0.000000 using: Poisson test stat Sample: ND_CCPi0 update w2: false LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_CCPi0 update w2: false LLH is: 272.910885 using: IceCube test stat +Sample: ND_CCPi0 update w2: false LLH is: 272.610039 using: IceCube test stat Sample: ND_CCPi0 update w2: false LLH is: 0.000000 using: Pearson test stat Sample: ND_CCPi0 update w2: false LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_CCPi0.txt: @@ -444098,7 +444098,7 @@ Contents of Rates_Debug_ND_CCPi0.txt: Sample: ND_NC0pi update w2: false LLH is: 0.000000 using: Poisson test stat Sample: ND_NC0pi update w2: false LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_NC0pi update w2: false LLH is: 144.116287 using: IceCube test stat +Sample: ND_NC0pi update w2: false LLH is: 143.696831 using: IceCube test stat Sample: ND_NC0pi update w2: false LLH is: 0.000000 using: Pearson test stat Sample: ND_NC0pi update w2: false LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_NC0pi.txt: @@ -444124,7 +444124,7 @@ Contents of Rates_Debug_ND_NC0pi.txt: Sample: ND_NC1pi0 update w2: false LLH is: 0.000000 using: Poisson test stat Sample: ND_NC1pi0 update w2: false LLH is: 0.000000 using: Barlow-Beeston test stat -Sample: ND_NC1pi0 update w2: false LLH is: 55.386077 using: IceCube test stat +Sample: ND_NC1pi0 update w2: false LLH is: 55.199269 using: IceCube test stat Sample: ND_NC1pi0 update w2: false LLH is: 0.000000 using: Pearson test stat Sample: ND_NC1pi0 update w2: false LLH is: 0.000000 using: Dembinski-Abdelmotteleb test stat Contents of Rates_Debug_ND_NC1pi0.txt: @@ -444150,33 +444150,33 @@ Contents of Rates_Debug_ND_NC1pi0.txt: Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml Rates Prior: 20125.192000 -Likelihood: 17190.607414 +Likelihood: 17141.481720 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 7070.364475 -Likelihood: 10120.242940 +Rates Prior: 7067.803433 +Likelihood: 10073.678286 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 2406.078134 -Likelihood: 7714.164805 +Rates Prior: 2384.678286 +Likelihood: 7689.000000 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 6231.164805 -Likelihood: 1483.000000 +Rates Prior: 6220.000000 +Likelihood: 1469.000000 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 1483.000000 +Rates Prior: 1469.000000 Likelihood: 0.000000 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml Rates Prior: 20125.192000 -Likelihood: 17190.607414 +Likelihood: 17141.481720 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 7070.364475 -Likelihood: 10120.242940 +Rates Prior: 7067.803433 +Likelihood: 10073.678286 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 2406.078134 -Likelihood: 7714.164805 +Rates Prior: 2384.678286 +Likelihood: 7689.000000 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 6231.164805 -Likelihood: 1483.000000 +Rates Prior: 6220.000000 +Likelihood: 1469.000000 Info for sample: TutorialConfigs/Samples/SampleHandler_Tutorial_ND.yaml -Rates Prior: 1483.000000 +Rates Prior: 1469.000000 Likelihood: 0.000000 TestStatistic Poisson, Data: 0.000000, MC: 0.000000, w²: 0.000000, LLH: 0.000000 TestStatistic Poisson, Data: 0.000000, MC: 0.000000, w²: 0.000010, LLH: 0.000000