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) {}
43 double chi2 = chi1_() + chi2_() + chi3_() + chi4_() + chi5_() + chi6_();
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() +
59 chi5_.numberOfBins() + chi6_.numberOfBins();
62 const T1 &
function1()
const {
return chi1_.function(); }
64 const T2 &
function2()
const {
return chi2_.function(); }
66 const T3 &
function3()
const {
return chi3_.function(); }
68 const T4 &
function4()
const {
return chi4_.function(); }
70 const T5 &
function5()
const {
return chi5_.function(); }
72 const T6 &
function6()
const {
return chi6_.function(); }
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) {}
106 double chi2 = chi1_() + chi2_() + chi3_() + chi4_() + chi5_();
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();
123 const T1 &
function1()
const {
return chi1_.function(); }
125 const T2 &
function2()
const {
return chi2_.function(); }
127 const T3 &
function3()
const {
return chi3_.function(); }
129 const T4 &
function4()
const {
return chi4_.function(); }
131 const T5 &
function5()
const {
return chi5_.function(); }
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) {}
161 double chi2 = chi1_() + chi2_() + chi3_() + chi4_();
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();
176 const T1 &
function1()
const {
return chi1_.function(); }
178 const T2 &
function2()
const {
return chi2_.function(); }
180 const T3 &
function3()
const {
return chi3_.function(); }
182 const T4 &
function4()
const {
return chi4_.function(); }
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) {}
206 double operator()()
const {
return chi1_() + chi2_() + chi3_(); }
208 chi1_.setHistos(histo1);
209 chi2_.setHistos(histo2);
210 chi3_.setHistos(histo3);
212 size_t numberOfBins()
const {
return chi1_.numberOfBins() + chi2_.numberOfBins() + chi3_.numberOfBins(); }
214 const T1 &
function1()
const {
return chi1_.function(); }
216 const T2 &
function2()
const {
return chi2_.function(); }
218 const T3 &
function3()
const {
return chi3_.function(); }
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);
243 size_t numberOfBins()
const {
return chi1_.numberOfBins() + chi2_.numberOfBins(); }
250 template <
typename T1>
252 helper::MultiHistoChiSquareNoArg,
259 template <
typename TT1>
261 : chi1_(t1, histo1, rangeMin, rangeMax) {}
263 void setHistos(TH1 *histo1) { chi1_.setHistos(histo1); }
270 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
273 unsigned int numberOfFreeParameters,
276 std::cout <<
"chi-squared/n.d.o.f. = " << amin <<
"/" << ndof <<
" = " << amin / ndof
277 <<
"; prob: " << TMath::Prob(amin, ndof) << std::endl;
size_t numberOfBins() const
const T6 & function6() const
double operator()() const
const T1 & function1() const
size_t numberOfBins() const
void setHistos(TH1 *histo1, TH1 *histo2)
const T1 & function1() const
double operator()() const
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, TT3 &t3, TH1 *histo3, TT4 &t4, TH1 *histo4, TT5 &t5, TH1 *histo5, double rangeMin, double rangeMax)
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, double rangeMin, double rangeMax)
const T3 & function3() const
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, double rangeMin, double rangeMax)
const T2 & function2() const
void setHistos(TH1 *histo1)
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, TT3 &t3, TH1 *histo3, TT4 &t4, TH1 *histo4, TT5 &t5, TH1 *histo5, TT6 &t6, TH1 *histo6, double rangeMin, double rangeMax)
size_t numberOfBins() const
double operator()() const
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, TT3 &t3, TH1 *histo3, double rangeMin, double rangeMax)
const T5 & function5() const
size_t numberOfBins() const
const T1 & function1() const
const T4 & function4() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4, TH1 *histo5, TH1 *histo6)
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, TT3 &t3, TH1 *histo3, TT4 &t4, TH1 *histo4, double rangeMin, double rangeMax)
const T4 & function4() const
double operator()() const
const T3 & function3() const
const T3 & function3() const
size_t numberOfBins() const
const T2 & function2() const
const T2 & function2() const
const T5 & function5() const
size_t numberOfBins() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4, TH1 *histo5)
double operator()() const
double operator()() const
static void print(double amin, unsigned int numberOfFreeParameters, const MultiHistoChiSquare< T1, T2, T3, T4, T5, T6 > &f)
const T4 & function4() const
const T1 & function1() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4)
const T2 & function2() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3)
const T3 & function3() const