35 for (
int i = 0; i <
binnum; i++)
36 for (
int j = 0; j <
binnum; j++)
42 for (
int i = 0; i <
binnum; i++)
48 for (
int j = 0; j <
binnum; j++)
56 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::SetData");
59 MSGUser()->MSG_ERROR(
"Negative index!!! Index should be positive!!!");
65 MSGUser()->MSG_ERROR(
"Index larger than binnum");
69 MSGUser()->MSG_DEBUG(
"The value of No.", index,
" bin for Reco-Data is set to ", value);
76 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::SetTheory");
79 MSGUser()->MSG_ERROR(
"Negative index!!! Index should be positive!!!");
85 MSGUser()->MSG_ERROR(
"Index larger than binnum");
89 MSGUser()->MSG_DEBUG(
"The value of No.", index,
" bin for Truth-MC is set to ", value);
96 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::SetMatrix");
99 MSGUser()->MSG_ERROR(
"Negative index!!! Index should be positive!!!");
105 MSGUser()->MSG_ERROR(
"Index larger than binnum");
111 MSGUser()->MSG_ERROR(
"Negative index!!! Index should be positive!!!");
117 MSGUser()->MSG_ERROR(
"Index larger than binnum");
121 MSGUser()->MSG_DEBUG(
"The value of No.", indexi,
",", indexj,
" bin for R-Matrix is set to ", value);
128 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::SetFiducial");
131 MSGUser()->MSG_ERROR(
"Negative index!!! Index should be positive!!!");
137 MSGUser()->MSG_ERROR(
"Index larger than binnum");
141 MSGUser()->MSG_DEBUG(
"The value of No.", index,
" bin for Fiducial is set to ", value);
148 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::SetEfficiency");
151 MSGUser()->MSG_ERROR(
"Negative index!!! Index should be positive!!!");
157 MSGUser()->MSG_ERROR(
"Index larger than binnum");
161 MSGUser()->MSG_DEBUG(
"The value of No.", index,
" bin for Efficiency is set to ", value);
170 for (
int j = 0; j <
binnum; j++)
173 for (
int k = 0; k <
binnum; k++)
176 for (
int i = 0; i <
binnum; i++)
183 for (
int i = 0; i <
binnum; i++)
189 for (
int j = 0; j <
binnum; j++)
196 for (
int i = 0; i <
binnum; i++)
201 for (
int j = 0; j <
binnum; j++)
215 for (
int i = 0; i <
binnum; i++)
224 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::PrintResult");
225 MSGUser()->MSG_DEBUG(
"Binnum Data Theory Original-Data");
226 for (
int i = 0; i <
binnum; i++)
232 for (
int i = 0; i <
binnum; i++)
241 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::BayesUnfold");
244 MSGUser()->MSG_ERROR(
"Check Failed");
248 for (
int i = 0; i <
binnum; i++)
255 bool SaveLess =
false;
256 if (iteration > 10000)
259 MSGUser()->MSG_DEBUG(
"Too many iterations, save only 1, 10, 100, ... iteration");
263 for (
int i = 0; i < iteration; i++)
265 MSGUser()->MSG_DEBUG(
"Iteration ", i,
" Start");
271 if (i == saveitr && SaveLess)
274 saveitr = saveitr * 10;
279 MSGUser()->MSG_DEBUG(
"Iteration ", i,
" End");
285 for (
int i = 0; i <
binnum; i++)
288 for (
int j = 0; j <
binnum; j++)
292 for (
int i = 0; i <
binnum; i++)
298 for (
int i = 0; i <
binnum; i++)
308 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::ReweightUnfold");
311 MSGUser()->MSG_ERROR(
"Check Failed");
316 for (
int i = 0; i <
binnum; i++)
319 for (
int i = 0; i <
binnum; i++)
326 bool keepdoing =
false;
327 int reweight_count = 0;
338 for (
int j = 0; j <
binnum; j++)
351 if (reweight_count > 2000)
354 MSGUser()->MSG_DEBUG(
"Reweight No.", reweight_count,
" Chi-square: ", chi2);
358 MSGUser()->MSG_DEBUG(
"Reweight No.", reweight_count,
" Chi-square: ", chi2);
360 iteration = reweight_count;
366 for (
int i = 0; i <
binnum; i++)
370 for (
int i = 0; i <
binnum; i++)
371 for (
int j = 0; j <
binnum; j++)
382 std::cout <<
"Iteration No." << i <<
" ";
383 for (
int j = 0; j <
binnum; j++)
385 std::cout << std::endl;
391 auto guard =
MSGUser()->StartTitleWithGuard(
"UnfoldTool::GetResult");
392 if (result ==
nullptr)
394 MSGUser()->MSG_ERROR(
"Hist for result is not set!!!");
398 if (result->GetNbinsX() <
binnum)
400 MSGUser()->MSG_ERROR(
"Not enought bins for the result!!!");
404 for (
int i = 0; i <
binnum; i++)
407 result->SetBinError(i + 1, 0);