1 #ifndef PhysicsTools_Utilities_MultiHistoChiSquare_h 2 #define PhysicsTools_Utilities_MultiHistoChiSquare_h 21 template<
typename TT1,
typename TT2,
typename TT3,
typename TT4,
typename TT5,
typename TT6>
23 TT2 & t2, TH1 *histo2,
24 TT3 & t3, TH1 *histo3,
25 TT4 & t4, TH1 *histo4,
26 TT5 & t5, TH1 *histo5,
27 TT6 & t6, TH1 *histo6,
29 chi1_(t1, histo1, rangeMin, rangeMax),
30 chi2_(t2, histo2, rangeMin, rangeMax),
31 chi3_(t3, histo3, rangeMin, rangeMax),
32 chi4_(t4, histo4, rangeMin, rangeMax),
33 chi5_(t5, histo5, rangeMin, rangeMax),
34 chi6_(t6, histo6, rangeMin, rangeMax) {
37 double chi2 = chi1_() + chi2_() + chi3_() + chi4_() + chi5_() + chi6_();
38 static size_t count = 0;
44 void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 * histo4, TH1 * histo5, TH1 * histo6 ) {
45 chi1_.setHistos(histo1);
46 chi2_.setHistos(histo2);
47 chi3_.setHistos(histo3);
48 chi4_.setHistos(histo4);
49 chi5_.setHistos(histo5);
50 chi6_.setHistos(histo6);
54 chi1_.numberOfBins() +
55 chi2_.numberOfBins() +
56 chi3_.numberOfBins() +
57 chi4_.numberOfBins() +
58 chi5_.numberOfBins() +
59 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(); }
84 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
86 helper::MultiHistoChiSquareNoArg> {
89 template<
typename TT1,
typename TT2,
typename TT3,
typename TT4,
typename TT5>
91 TT2 & t2, TH1 *histo2,
92 TT3 & t3, TH1 *histo3,
93 TT4 & t4, TH1 *histo4,
94 TT5 & t5, TH1 *histo5,
96 chi1_(t1, histo1, rangeMin, rangeMax),
97 chi2_(t2, histo2, rangeMin, rangeMax),
98 chi3_(t3, histo3, rangeMin, rangeMax),
99 chi4_(t4, histo4, rangeMin, rangeMax),
100 chi5_(t5, histo5, rangeMin, rangeMax) {
103 double chi2 = chi1_() + chi2_() + chi3_() + chi4_() + chi5_();
104 static size_t count = 0;
108 void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 * histo4, TH1 * histo5) {
109 chi1_.setHistos(histo1);
110 chi2_.setHistos(histo2);
111 chi3_.setHistos(histo3);
112 chi4_.setHistos(histo4);
113 chi5_.setHistos(histo5);
117 chi1_.numberOfBins() +
118 chi2_.numberOfBins() +
119 chi3_.numberOfBins() +
120 chi4_.numberOfBins() +
121 chi5_.numberOfBins();
124 const T1 &
function1()
const {
return chi1_.function(); }
126 const T2 &
function2()
const {
return chi2_.function(); }
128 const T3 &
function3()
const {
return chi3_.function(); }
130 const T4 &
function4()
const {
return chi4_.function(); }
132 const T5 &
function5()
const {
return chi5_.function(); }
141 template<
typename T1,
typename T2,
typename T3,
typename T4>
143 helper::MultiHistoChiSquareNoArg,
147 template<
typename TT1,
typename TT2,
typename TT3,
typename TT4>
149 TT2 & t2, TH1 *histo2,
150 TT3 & t3, TH1 *histo3,
151 TT4 & t4, TH1 *histo4,
153 chi1_(t1, histo1, rangeMin, rangeMax),
154 chi2_(t2, histo2, rangeMin, rangeMax),
155 chi3_(t3, histo3, rangeMin, rangeMax),
156 chi4_(t4, histo4, rangeMin, rangeMax) {
159 double chi2 = chi1_() + chi2_() + chi3_() + chi4_();
160 static size_t count = 0;
164 void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 * histo4) {
165 chi1_.setHistos(histo1);
166 chi2_.setHistos(histo2);
167 chi3_.setHistos(histo3);
168 chi4_.setHistos(histo4);
172 chi1_.numberOfBins() +
173 chi2_.numberOfBins() +
174 chi3_.numberOfBins() +
175 chi4_.numberOfBins();
178 const T1 &
function1()
const {
return chi1_.function(); }
180 const T2 &
function2()
const {
return chi2_.function(); }
182 const T3 &
function3()
const {
return chi3_.function(); }
184 const T4 &
function4()
const {
return chi4_.function(); }
193 template<
typename T1,
typename T2,
typename T3>
199 template<
typename TT1,
typename TT2,
typename TT3>
201 TT2 & t2, TH1 *histo2,
202 TT3 & t3, TH1 *histo3,
204 chi1_(t1, histo1, rangeMin, rangeMax),
205 chi2_(t2, histo2, rangeMin, rangeMax),
206 chi3_(t3, histo3, rangeMin, rangeMax) {
209 return chi1_() + chi2_() + chi3_();
212 chi1_.setHistos(histo1);
213 chi2_.setHistos(histo2);
214 chi3_.setHistos(histo3);
218 chi1_.numberOfBins() +
219 chi2_.numberOfBins() +
220 chi3_.numberOfBins();
223 const T1 &
function1()
const {
return chi1_.function(); }
225 const T2 &
function2()
const {
return chi2_.function(); }
227 const T3 &
function3()
const {
return chi3_.function(); }
234 template<
typename T1,
typename T2>
236 helper::MultiHistoChiSquareNoArg,
242 template<
typename TT1,
typename TT2>
244 TT2 & t2, TH1 *histo2,
246 chi1_(t1, histo1, rangeMin, rangeMax),
247 chi2_(t2, histo2, rangeMin, rangeMax) {
250 return chi1_() + chi2_();
253 chi1_.setHistos(histo1);
254 chi2_.setHistos(histo2);
258 chi1_.numberOfBins() +
259 chi2_.numberOfBins();
266 template<
typename T1>
268 helper::MultiHistoChiSquareNoArg,
275 template<
typename TT1>
277 : chi1_(t1, histo1, rangeMin, rangeMax) {
283 chi1_.setHistos(histo1);
286 return chi1_.numberOfBins();
292 template<
typename T1,
typename T2,
typename T3,
293 typename T4,
typename T5,
typename T6>
295 static void print(
double amin,
unsigned int numberOfFreeParameters,
298 std::cout <<
"chi-squared/n.d.o.f. = " << amin <<
"/" << ndof <<
" = " << amin/ndof
299 <<
"; prob: " << TMath::Prob(amin, ndof)
double operator()() const
const T3 & function3() const
const T6 & function6() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3)
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, TT3 &t3, TH1 *histo3, TT4 &t4, TH1 *histo4, double rangeMin, double rangeMax)
const T5 & function5() const
size_t numberOfBins() const
const T3 & function3() const
double operator()() const
const T1 & function1() const
size_t numberOfBins() const
double operator()() const
const T2 & function2() 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)
const T2 & function2() const
size_t numberOfBins() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4, TH1 *histo5)
const T4 & function4() const
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)
const T1 & function1() const
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, double rangeMin, double rangeMax)
const T4 & function4() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4)
double operator()() const
const T5 & function5() const
size_t numberOfBins() const
double operator()() const
void setHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3, TH1 *histo4, TH1 *histo5, TH1 *histo6)
const T3 & function3() const
double operator()() const
void setHistos(TH1 *histo1, TH1 *histo2)
const T1 & function1() const
void setHistos(TH1 *histo1)
const T2 & function2() const
size_t numberOfBins() const
const T2 & function2() const
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, TT2 &t2, TH1 *histo2, TT3 &t3, TH1 *histo3, double rangeMin, double rangeMax)
MultiHistoChiSquare(TT1 &t1, TH1 *histo1, double rangeMin, double rangeMax)
const T1 & function1() const
static void print(double amin, unsigned int numberOfFreeParameters, const MultiHistoChiSquare< T1, T2, T3, T4, T5, T6 > &f)
const T4 & function4() const
size_t numberOfBins() const
const T3 & function3() const