1 #ifndef PhysicsTools_Utilities_MultiHistoChiSquare_h
2 #define PhysicsTools_Utilities_MultiHistoChiSquare_h
12 template <
typename T1,
21 template <
typename TT1,
typename TT2,
typename TT3,
typename TT4,
typename TT5,
typename TT6>
36 :
chi1_(
t1, histo1, rangeMin, rangeMax),
37 chi2_(
t2, histo2, rangeMin, rangeMax),
38 chi3_(
t3, histo3, rangeMin, rangeMax),
39 chi4_(t4, histo4, rangeMin, rangeMax),
40 chi5_(t5, histo5, rangeMin, rangeMax),
41 chi6_(t6, histo6, rangeMin, rangeMax) {}
44 static size_t count = 0;
49 void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4, TH1 *histo5, TH1 *histo6) {
50 chi1_.setHistos(histo1);
51 chi2_.setHistos(histo2);
52 chi3_.setHistos(histo3);
53 chi4_.setHistos(histo4);
54 chi5_.setHistos(histo5);
55 chi6_.setHistos(histo6);
58 return chi1_.numberOfBins() +
chi2_.numberOfBins() +
chi3_.numberOfBins() +
chi4_.numberOfBins() +
83 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
87 template <
typename TT1,
typename TT2,
typename TT3,
typename TT4,
typename TT5>
100 :
chi1_(
t1, histo1, rangeMin, rangeMax),
101 chi2_(
t2, histo2, rangeMin, rangeMax),
102 chi3_(
t3, histo3, rangeMin, rangeMax),
103 chi4_(t4, histo4, rangeMin, rangeMax),
104 chi5_(t5, histo5, rangeMin, rangeMax) {}
107 static size_t count = 0;
111 void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4, TH1 *histo5) {
112 chi1_.setHistos(histo1);
113 chi2_.setHistos(histo2);
114 chi3_.setHistos(histo3);
115 chi4_.setHistos(histo4);
116 chi5_.setHistos(histo5);
119 return chi1_.numberOfBins() +
chi2_.numberOfBins() +
chi3_.numberOfBins() +
chi4_.numberOfBins() +
120 chi5_.numberOfBins();
141 template <
typename T1,
typename T2,
typename T3,
typename T4>
145 template <
typename TT1,
typename TT2,
typename TT3,
typename TT4>
156 :
chi1_(
t1, histo1, rangeMin, rangeMax),
157 chi2_(
t2, histo2, rangeMin, rangeMax),
158 chi3_(
t3, histo3, rangeMin, rangeMax),
159 chi4_(t4, histo4, rangeMin, rangeMax) {}
162 static size_t count = 0;
166 void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4) {
167 chi1_.setHistos(histo1);
168 chi2_.setHistos(histo2);
169 chi3_.setHistos(histo3);
170 chi4_.setHistos(histo4);
173 return chi1_.numberOfBins() +
chi2_.numberOfBins() +
chi3_.numberOfBins() +
chi4_.numberOfBins();
191 template <
typename T1,
typename T2,
typename T3>
195 helper::MultiHistoChiSquareNoArg,
200 template <
typename TT1,
typename TT2,
typename TT3>
202 TT1 &
t1, TH1 *histo1, TT2 &
t2, TH1 *histo2, TT3 &
t3, TH1 *histo3,
double rangeMin,
double rangeMax)
203 :
chi1_(
t1, histo1, rangeMin, rangeMax),
204 chi2_(
t2, histo2, rangeMin, rangeMax),
205 chi3_(
t3, histo3, rangeMin, rangeMax) {}
208 chi1_.setHistos(histo1);
209 chi2_.setHistos(histo2);
210 chi3_.setHistos(histo3);
226 template <
typename T1,
typename T2>
229 helper::MultiHistoChiSquareNoArg,
235 template <
typename TT1,
typename TT2>
237 :
chi1_(
t1, histo1, rangeMin, rangeMax),
chi2_(
t2, histo2, rangeMin, rangeMax) {}
240 chi1_.setHistos(histo1);
241 chi2_.setHistos(histo2);
250 template <
typename T1>
252 helper::MultiHistoChiSquareNoArg,
259 template <
typename TT1>
261 :
chi1_(
t1, histo1, rangeMin, rangeMax) {}
270 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
273 unsigned int numberOfFreeParameters,
275 unsigned int ndof =
f.numberOfBins() - numberOfFreeParameters;
276 std::cout <<
"chi-squared/n.d.o.f. = " << amin <<
"/" <<
ndof <<
" = " << amin /
ndof
277 <<
"; prob: " << TMath::Prob(amin,
ndof) << std::endl;