Jpp 20.0.0-rc.7
the software that should make you happy
Loading...
Searching...
No Matches
JPseudoExperiment.hh
Go to the documentation of this file.
1#ifndef __JASTRONOMY__JPSEUDOEXPERIMENT__
2#define __JASTRONOMY__JPSEUDOEXPERIMENT__
3
4#include <istream>
5#include <ostream>
6#include <vector>
7#include <algorithm>
8#include <limits>
9
10#include "TObject.h"
11#include "TH1.h"
12#include "TH2.h"
13#include "TH3.h"
14#include "TRandom3.h"
15
17#include "JAstronomy/JAspera.hh"
19
20
21/**
22 * \file
23 *
24 * Pseudo experiment.
25 * \author mdejong
26 */
27namespace JASTRONOMY {}
28namespace JPP { using namespace JASTRONOMY; }
29
30namespace JASTRONOMY {
31
32
33 /**
34 * Auxiliary interface for pseudo experiment.
35 */
37 public JExperiment
38 {
39 /**
40 * Statistics of pseudo experiment.
41 */
42 struct stats_type {
43 /**
44 * Addition operator.
45 *
46 * \param px statistics of pseudo experiment
47 * \return this statistics
48 */
50 {
51 this->ns += px.ns;
52 this->nb += px.nb;
53
54 return *this;
55 }
56
57 size_t ns = 0; //!< number of generated signal events
58 size_t nb = 0; //!< number of generated background events
59 };
60
61
62 typedef JAspera::fit_type fit_type; //!< fit type
63
64
65 /**
66 * Combined result of pseudo experiment and fit.
67 */
68 struct result_type :
69 public stats_type,
70 public fit_type
71 {};
72
73
74 /**
75 * Set scaling factors of signal and background strengths.
76 *
77 * \param fS signal strength
78 * \param fB background strength
79 */
80 virtual void set(const double fS, const double fB = 1.0) = 0;
81
82
83 /**
84 * Get fit method.
85 *
86 * \return fit
87 */
88 virtual JAspera& getAspera() = 0;
89
90
91 /**
92 * Generate pseudo experiment and transfer S/N values to fit method.
93 *
94 * \param out output
95 * \return result
96 */
97 virtual stats_type run(JAspera& out) const = 0;
98
99
100 /**
101 * Generate background only pseudo experiment and transfer S/N values to fit method.
102 *
103 * \param out output
104 * \param nb number of background events
105 * \return result
106 */
107 virtual stats_type run(JAspera& out, const size_t nb) const = 0;
108
109
110 /**
111 * Generate pseudo experiment and fit signal strength.
112 *
113 * \return result
114 */
116 {
117 JAspera& aspera = getAspera();
118
119 // reset
120
121 aspera.clear();
122 aspera.setSignal(0.0);
123
124 return { run(aspera), aspera() };
125 }
126
127
128 /**
129 * Generate background only pseudo experiment and fit signal strength.
130 *
131 * \param nb number of background events
132 * \return result
133 */
134 inline result_type operator()(const size_t nb)
135 {
136 JAspera& aspera = getAspera();
137
138 // reset
139
140 aspera.clear();
141 aspera.setSignal(0.0);
142
143 return { run(aspera, nb), aspera() };
144 }
145
146
147 /**
148 * Run pseudo experiments using given storage.
149 *
150 * \param storage storage
151 */
153 {
154 for (auto& i : storage) {
155 i = (*this)();
156 }
157 }
158
159
160 /**
161 * Run pseudo experiments using given storage.
162 *
163 * \param pm pointer to data member of result
164 * \param storage storage
165 */
166 template<class T, class JValue_t>
167 inline void operator()(JValue_t result_type::*pm, std::vector<T>& storage)
168 {
169 for (auto& i : storage) {
170 i = (*this)().*pm;
171 }
172 }
173
174
175 /**
176 * Run pseudo experiments using given storage.
177 *
178 * \param pm pointer to data member of result
179 * \param storage storage
180 */
181 template<class T, class JValue_t>
182 inline void operator()(JValue_t JAspera::fit_type::*pm, std::vector<T>& storage)
183 {
184 (*this)(static_cast<JValue_t result_type::*>(pm), storage);
185 }
186
187
188 static constexpr double MINIMAL_SIGNAL_STRENGTH = 1.0e-10; // minimal signal strength for upper limit
189 static constexpr double MAXIMAL_SIGNAL_STRENGTH = 1.0e+10; // maximal signal strength for upper limit
190
191
192 /**
193 * Get signal strength given result of experiment and probability of upper limit.
194 *
195 * \param aspera result of experiment
196 * \param Q probability
197 * \param numberOfTests number of tests
198 * \param precision precision
199 * \return signal strength
200 */
202 const double Q,
203 const size_t numberOfTests,
204 const double precision = 1.0e-4)
205 {
206 using namespace std;
207
208 const JAspera::fit_type result = aspera(true);
209
210 size_t n = 0;
211
212 this->set(0.0);
213
214 for (size_t i = 0; i != numberOfTests; ++i) {
215
216 JAspera aspera;
217
218 this->run(aspera);
219
220 if (aspera(true).signal < result.signal) {
221 n += 1;
222 }
223 }
224
225 if (n > (1.0 - Q) * numberOfTests) {
226
227 double mumin = 1.0;
228 double mumax = 1.0;
229
230 {
231 for ( ; ; mumax *= 2.0) {
232
233 const double ts = aspera.getTestStatisticForUpperLimit(mumax);
234
235 this->set(mumax);
236
237 const double ps = this->getProbabilityForUpperLimit(mumax, ts, numberOfTests);
238
239 if (ps < 1.0 - Q || mumax > MAXIMAL_SIGNAL_STRENGTH) {
240 break;
241 }
242 }
243 }
244
245 if (mumax == 1.0) {
246
247 mumin = 0.5*mumax;
248
249 for ( ; ; mumin *= 0.5) {
250
251 const double ts = aspera.getTestStatisticForUpperLimit(mumin);
252
253 this->set(mumin);
254
255 const double ps = this->getProbabilityForUpperLimit(mumin, ts, numberOfTests);
256
257 if (ps > 1.0 - Q || mumin < MINIMAL_SIGNAL_STRENGTH) {
258 break;
259 }
260 }
261
262 mumax = 2.0*mumin;
263
264 } else {
265
266 mumin = 0.5*mumax;
267 }
268
269 if (mumin < MINIMAL_SIGNAL_STRENGTH)
270 return mumin;
271 else if (mumax > MAXIMAL_SIGNAL_STRENGTH)
272 return mumax;
273 else {
274
275 for ( ; ; ) { // binary search
276
277 const double mu = 0.5 * (mumin + mumax);
278
279 const double ts = aspera.getTestStatisticForUpperLimit(mu);
280
281 this->set(mu);
282
283 const double ps = this->getProbabilityForUpperLimit(mu, ts, numberOfTests);
284
285 if (fabs(ps - (1.0 - Q)) <= precision) {
286 return mu;
287 }
288
289 if (ps >= 1.0 - Q)
290 mumin = mu;
291 else
292 mumax = mu;
293 }
294 }
295 }
296
297 return 0.0;
298 }
299
300 protected:
301 /**
302 * Get probability for given pseudo experiment and signal strength to exceed minimal test statistic for upper limit.
303 *
304 * \param ps signal strength
305 * \param ts test statistic
306 * \param nx number of pseudo experiments
307 */
308 inline double getProbabilityForUpperLimit(const double ps,
309 const double ts,
310 const size_t nx) const
311 {
312 size_t ns = 0;
313
314 for (size_t i = 0; i != nx; ++i) {
315
316 JAspera aspera;
317
318 this->run(aspera);
319
320 if (ps <= std::numeric_limits<double>::min()) {
321
322 if (aspera().signal <= ps) {
323 ns += 1;
324 }
325
326 } else if (aspera.getTestStatisticForUpperLimit(ps) > ts) {
327 ns += 1;
328 }
329 }
330
331 return (double) ns / (double) nx;
332 }
333 };
334
335
336 /**
337 * Pseudo experiment using CDF for combined generation and likelihood evaluation.
338 */
341 {
342 using JPseudoExperiment_t::operator();
343
344 /**
345 * Default constructor.
346 */
349
350
351 /**
352 * Constructor.
353 *
354 * \param hs histogram with PDF of signal
355 * \param hb histogram with PDF of background
356 */
357 template<class H_t>
358 JPseudoExperiment(const H_t& hs,
359 const H_t& hb)
360 {
361 add(hs, hb);
362 }
363
364
365 /**
366 * Constructor.
367 *
368 * \param hS histogram with PDF for generation of signal
369 * \param hB histogram with PDF for generation of background
370 * \param hs histogram with PDF for evaluation of signal
371 * \param hb histogram with PDF for evaluation of background
372 */
373 template<class H_t>
374 JPseudoExperiment(const H_t& hS,
375 const H_t& hB,
376 const H_t& hs,
377 const H_t& hb)
378 {
379 add(hS, hB, hs, hb);
380 }
381
382
383 /**
384 * Add objects with PDFs of signal and background.
385 *
386 * \param ps pointer to object with PDF of signal
387 * \param pb pointer to object with PDF of background
388 */
389 void add(const TObject* ps,
390 const TObject* pb)
391 {
392 if (add<TH3>(ps, pb)) { return; }
393 if (add<TH2>(ps, pb)) { return; }
394 if (add<TH1>(ps, pb)) { return; }
395 }
396
397
398 /**
399 * Add objects with PDFs of signal and background.
400 *
401 * \param pS pointer to object with PDF for generation of signal
402 * \param pB pointer to object with PDF for generation of background
403 * \param ps pointer to object with PDF for evaluation of signal
404 * \param pb pointer to object with PDF for evaluation of background
405 */
406 void add(const TObject* pS,
407 const TObject* pB,
408 const TObject* ps,
409 const TObject* pb)
410 {
411 if (add<TH3>(pS, pB, ps, pb)) { return; }
412 if (add<TH2>(pS, pB, ps, pb)) { return; }
413 if (add<TH1>(pS, pB, ps, pb)) { return; }
414 }
415
416
417 /**
418 * Add histograms with PDFs of signal and background.
419 *
420 * \param hs histogram with PDF of signal
421 * \param hb histogram with PDF of background
422 */
423 void add(const TH1& hs,
424 const TH1& hb)
425 {
426 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
427 add(hs.GetBinContent(ix),
428 hb.GetBinContent(ix));
429 }
430 }
431
432
433 /**
434 * Add histograms with PDFs of signal and background.
435 *
436 * \param hS histogram with PDF for generation of signal
437 * \param hB histogram with PDF for generation of background
438 * \param hs histogram with PDF for evaluation of signal
439 * \param hb histogram with PDF for evaluation of background
440 */
441 void add(const TH1& hS,
442 const TH1& hB,
443 const TH1& hs,
444 const TH1& hb)
445 {
446 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
447 add(hS.GetBinContent(ix),
448 hB.GetBinContent(ix),
449 hs.GetBinContent(ix),
450 hb.GetBinContent(ix));
451 }
452 }
453
454
455 /**
456 * Add histograms with PDFs of signal and background.
457 *
458 * \param hs histogram with PDF of signal
459 * \param hb histogram with PDF of background
460 */
461 void add(const TH2& hs,
462 const TH2& hb)
463 {
464 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
465 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
466 add(hs.GetBinContent(ix, iy),
467 hb.GetBinContent(ix, iy));
468 }
469 }
470 }
471
472
473 /**
474 * Add histograms with PDFs of signal and background.
475 *
476 * \param hS histogram with PDF for generation of signal
477 * \param hB histogram with PDF for generation of background
478 * \param hs histogram with PDF for evaluation of signal
479 * \param hb histogram with PDF for evaluation of background
480 */
481 void add(const TH2& hS,
482 const TH2& hB,
483 const TH2& hs,
484 const TH2& hb)
485 {
486 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
487 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
488 add(hS.GetBinContent(ix, iy),
489 hB.GetBinContent(ix, iy),
490 hs.GetBinContent(ix, iy),
491 hb.GetBinContent(ix, iy));
492 }
493 }
494 }
495
496
497 /**
498 * Add histograms with PDFs of signal and background.
499 *
500 * \param hs histogram with PDF of signal
501 * \param hb histogram with PDF of background
502 */
503 void add(const TH3& hs,
504 const TH3& hb)
505 {
506 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
507 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
508 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
509 add(hs.GetBinContent(ix, iy, iz),
510 hb.GetBinContent(ix, iy, iz));
511 }
512 }
513 }
514 }
515
516
517 /**
518 * Add histograms with PDFs of signal and background.
519 *
520 * \param hS histogram with PDF for generation of signal
521 * \param hB histogram with PDF for generation of background
522 * \param hs histogram with PDF for evaluation of signal
523 * \param hb histogram with PDF for evaluation of background
524 */
525 void add(const TH3& hS,
526 const TH3& hB,
527 const TH3& hs,
528 const TH3& hb)
529 {
530 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
531 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
532 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
533 add(hS.GetBinContent(ix, iy, iz),
534 hB.GetBinContent(ix, iy, iz),
535 hs.GetBinContent(ix, iy, iz),
536 hb.GetBinContent(ix, iy, iz));
537 }
538 }
539 }
540 }
541
542
543 /**
544 * Add signal and background.
545 *
546 * \param s signal
547 * \param b background
548 */
549 void add(const double s,
550 const double b)
551 {
552 if (check(s, b)) {
553
554 cs.put(s);
555 cb.put(b);
556
557 aspera.put(s, b);
558 }
559 }
560
561
562 /**
563 * Add signal and background.
564 *
565 * \param S signal for generation
566 * \param B background for generation
567 * \param s signal for evaluation
568 * \param b background for evaluation
569 */
570 void add(const double S,
571 const double B,
572 const double s,
573 const double b)
574 {
575 if (//check(S, B) &&
576 check(s, b)) {
577
578 cs.put(S);
579 cb.put(B);
580
581 aspera.put(s, b);
582 }
583 }
584
585
586 /**
587 * Get total signal.
588 *
589 * \return signal
590 */
591 double getSignal() const
592 {
593 return cs.back() * this->fs;
594 }
595
596
597 /**
598 * Get total background.
599 *
600 * \return background
601 */
602 double getBackground() const
603 {
604 return cb.back() * this->fb;
605 }
606
607
608 /**
609 * Set scaling factors of signal and background strengths.
610 *
611 * \param fS signal strength
612 * \param fB background strength
613 */
614 virtual void set(const double fS, const double fB = 1.0) override
615 {
616 for (auto& i : aspera) {
617 i *= fB / this->fb;
618 }
619
620 this->fs = fS;
621 this->fb = fB;
622 }
623
624
625 /**
626 * Get fit method.
627 *
628 * \return fit
629 */
630 virtual JAspera& getAspera() override
631 {
632 return this->fit;
633 }
634
635
636 /**
637 * Generate pseudo experiment and transfer values to fit method.
638 *
639 * \param out output
640 * \return result
641 */
642 virtual stats_type run(JAspera& out) const
643 {
645
646 const size_t ns = gRandom->Poisson(getSignal() * nuisance.signal ->get()); // number of signal events
647 const size_t nb = gRandom->Poisson(getBackground() * nuisance.background->get()); // number of background events
648
649 for (size_t i = ns; i != 0; --i) { out.push_back(aspera[cs.get_index(gRandom->Rndm())]); } // store distributed signal events
650 for (size_t i = nb; i != 0; --i) { out.push_back(aspera[cb.get_index(gRandom->Rndm())]); } // store distributed background events
651
652 return { ns, nb };
653 }
654
655
656 /**
657 * Generate background only pseudo experiment and transfer S/N values to fit method.
658 *
659 * \param out output
660 * \param nb number of background events
661 * \return result
662 */
663 virtual stats_type run(JAspera& out, const size_t nb) const
664 {
666
667 for (size_t i = nb; i != 0; --i) { out.push_back(aspera[cb.get_index(gRandom->Rndm())]); } // store distributed background events
668
669 return { 0, nb };
670 }
671
672
673 /**
674 * Nuisance parameters.
675 */
677
678 /**
679 * Read parameters from input stream.
680 *
681 * \param in input stream
682 * \param parameters parameters
683 * \return input stream
684 */
685 friend inline std::istream& operator>>(std::istream& in, parameters_type& parameters)
686 {
687 return in >> parameters.signal
688 >> parameters.background;
689 }
690
691
692 /**
693 * Write parameters to output stream.
694 *
695 * \param out output stream
696 * \param parameters parameters
697 * \return output stream
698 */
699 friend inline std::ostream& operator<<(std::ostream& out, const parameters_type& parameters)
700 {
701 return out << parameters.signal << ' '
702 << parameters.background;
703 }
704
707
709
710
711 /**
712 * Configure lookup tables.
713 *
714 * \param N number of bins
715 */
716 void configure(size_t N)
717 {
718 cs.configure(N);
719 cb.configure(N);
720 }
721
722 protected:
723 /**
724 * Add objects with PDF of signal and background.
725 *
726 * \param ps pointer to object with PDF of signal
727 * \param pb pointer to object with PDF of background
728 * \return true if added; else false
729 */
730 template<class H_t>
731 bool add(const TObject* ps,
732 const TObject* pb)
733 {
734 if (dynamic_cast<const H_t*>(ps) != NULL &&
735 dynamic_cast<const H_t*>(pb) != NULL) {
736
737 const H_t& hs = dynamic_cast<const H_t&>(*ps);
738 const H_t& hb = dynamic_cast<const H_t&>(*pb);
739
740 if (check(hs, hb)) {
741
742 add(hs, hb);
743
744 return true;
745 }
746 }
747
748 return false;
749 }
750
751
752 /**
753 * Add objects with PDF of signal and background.
754 *
755 * \param pS pointer to object with PDF for generation of signal
756 * \param pB pointer to object with PDF for generation of background
757 * \param ps pointer to object with PDF for evaluation of signal
758 * \param pb pointer to object with PDF for evaluation of background
759 * \return true if added; else false
760 */
761 template<class H_t>
762 bool add(const TObject* pS,
763 const TObject* pB,
764 const TObject* ps,
765 const TObject* pb)
766 {
767 if (dynamic_cast<const H_t*>(pS) != NULL &&
768 dynamic_cast<const H_t*>(pB) != NULL &&
769 dynamic_cast<const H_t*>(ps) != NULL &&
770 dynamic_cast<const H_t*>(pb) != NULL) {
771
772 const H_t& hS = dynamic_cast<const H_t&>(*pS);
773 const H_t& hB = dynamic_cast<const H_t&>(*pB);
774 const H_t& hs = dynamic_cast<const H_t&>(*ps);
775 const H_t& hb = dynamic_cast<const H_t&>(*pb);
776
777 if (check(hS, hB) && check(hB, hs) && check(hs, hb)) {
778
779 add(hS, hB, hs, hb);
780
781 return true;
782 }
783 }
784
785 return false;
786 }
787
788
789 /**
790 * Auxiliary data structure for CDF.
791 */
792 struct cdf_type :
793 public std::vector<double>
794 {
795 /**
796 * Configure lookup table to substitute binary search.
797 *
798 * \param N number of bins
799 */
800 void configure(size_t N)
801 {
802 if (this->size() > 1) {
803
804 index.resize(N);
805
806 size_t p = 0;
807
808 for (size_t i = 0; i != N; ++i) {
809
810 const double x = this->back() * (double) i / (double) N;
811
812 while ((*this)[p+1] < x) {
813 ++p;
814 }
815
816 index[i] = p;
817 }
818 }
819 }
820
821 /**
822 * Get index corresponding to given random value.
823 *
824 * \param rv random value [0,1>
825 * \param option option to force use of binary search
826 * \return index
827 */
828 inline size_t get_index(const double rv, const bool option = false) const
829 {
830 const double value = this->back() * rv;
831
832 if (option || index.empty()) {
833
834 size_t first = 0;
835 size_t count = this->size();
836
837 for (size_t i, step; count != 0; ) {
838
839 step = count / 2;
840 i = first + step;
841
842 if ((*this)[i] < value) {
843 first = ++i;
844 count -= step + 1;
845 } else {
846 count = step;
847 }
848 }
849
850 return first;
851
852 } else {
853
854 size_t i = index[rv * index.size()];
855
856 while (i != this->size() && (*this)[i] < value) {
857 ++i;
858 }
859
860 return i;
861 }
862 }
863
864
865 /**
866 * Put given value.
867 *
868 * \param x value
869 */
870 void put(const double x)
871 {
872 if (this->empty())
873 this->push_back(x);
874 else
875 this->push_back(this->back() + x);
876 }
877
878 private:
879 std::vector<size_t> index; //!< lookup table
880 };
881
882
883 cdf_type cs; //!< CDF of signal
884 cdf_type cb; //!< CDF of background
885
886 JAspera aspera; //!< pre-computed N/S values
887
888 double fs = 1.0; //!< scaling factor signal strength
889 double fb = 1.0; //!< scaling factor background strength
890
891 JAspera fit; //!< fit
892 };
893}
894
895#endif
Per aspera ad astra.
Experiment.
Nuisance parameter.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure to fit signal strength using likelihood ratio.
Definition JAspera.hh:24
void addSignal(const double wS)
Add signal strength.
Definition JAspera.hh:258
double getSignal() const
Get total signal strength.
Definition JAspera.hh:236
void setSignal(const double wS)
Set signal strength.
Definition JAspera.hh:247
void put(const double s, const double b)
Put signal and background to list of pre-computed N/S values.
Definition JAspera.hh:44
double getTestStatisticForUpperLimit(const double ps) const
Get test statistic for given signal strength.
Definition JAspera.hh:218
Auxiliary base class for experiment.
static bool check(const double s, const double b)
Check validity of signal and background.
Helper for nuisance I/O.
Definition JNuisance.hh:349
Auxiliary data structure for CDF.
void put(const double x)
Put given value.
std::vector< size_t > index
lookup table
size_t get_index(const double rv, const bool option=false) const
Get index corresponding to given random value.
void configure(size_t N)
Configure lookup table to substitute binary search.
friend std::ostream & operator<<(std::ostream &out, const parameters_type &parameters)
Write parameters to output stream.
friend std::istream & operator>>(std::istream &in, parameters_type &parameters)
Read parameters from input stream.
Combined result of pseudo experiment and fit.
size_t ns
number of generated signal events
size_t nb
number of generated background events
stats_type & operator+=(const stats_type &px)
Addition operator.
Auxiliary interface for pseudo experiment.
result_type operator()()
Generate pseudo experiment and fit signal strength.
virtual JAspera & getAspera()=0
Get fit method.
void operator()(JValue_t JAspera::fit_type::*pm, std::vector< T > &storage)
Run pseudo experiments using given storage.
double getSignalStrengthForUpperLimit(const JAspera &aspera, const double Q, const size_t numberOfTests, const double precision=1.0e-4)
Get signal strength given result of experiment and probability of upper limit.
result_type operator()(const size_t nb)
Generate background only pseudo experiment and fit signal strength.
void operator()(JValue_t result_type::*pm, std::vector< T > &storage)
Run pseudo experiments using given storage.
static constexpr double MINIMAL_SIGNAL_STRENGTH
virtual stats_type run(JAspera &out, const size_t nb) const =0
Generate background only pseudo experiment and transfer S/N values to fit method.
void operator()(std::vector< result_type > &storage)
Run pseudo experiments using given storage.
double getProbabilityForUpperLimit(const double ps, const double ts, const size_t nx) const
Get probability for given pseudo experiment and signal strength to exceed minimal test statistic for ...
virtual void set(const double fS, const double fB=1.0)=0
Set scaling factors of signal and background strengths.
static constexpr double MAXIMAL_SIGNAL_STRENGTH
virtual stats_type run(JAspera &out) const =0
Generate pseudo experiment and transfer S/N values to fit method.
JAspera::fit_type fit_type
fit type
Pseudo experiment using CDF for combined generation and likelihood evaluation.
void add(const TObject *ps, const TObject *pb)
Add objects with PDFs of signal and background.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
virtual stats_type run(JAspera &out, const size_t nb) const
Generate background only pseudo experiment and transfer S/N values to fit method.
virtual stats_type run(JAspera &out) const
Generate pseudo experiment and transfer values to fit method.
void add(const TH3 &hS, const TH3 &hB, const TH3 &hs, const TH3 &hb)
Add histograms with PDFs of signal and background.
void add(const TH1 &hS, const TH1 &hB, const TH1 &hs, const TH1 &hb)
Add histograms with PDFs of signal and background.
bool add(const TObject *ps, const TObject *pb)
Add objects with PDF of signal and background.
virtual JAspera & getAspera() override
Get fit method.
bool add(const TObject *pS, const TObject *pB, const TObject *ps, const TObject *pb)
Add objects with PDF of signal and background.
double getSignal() const
Get total signal.
void add(const TH2 &hS, const TH2 &hB, const TH2 &hs, const TH2 &hb)
Add histograms with PDFs of signal and background.
void add(const TH3 &hs, const TH3 &hb)
Add histograms with PDFs of signal and background.
JPseudoExperiment(const H_t &hS, const H_t &hB, const H_t &hs, const H_t &hb)
Constructor.
virtual void set(const double fS, const double fB=1.0) override
Set scaling factors of signal and background strengths.
double fb
scaling factor background strength
cdf_type cb
CDF of background.
void add(const double S, const double B, const double s, const double b)
Add signal and background.
void add(const TH2 &hs, const TH2 &hb)
Add histograms with PDFs of signal and background.
JPseudoExperiment(const H_t &hs, const H_t &hb)
Constructor.
JAspera aspera
pre-computed N/S values
double getBackground() const
Get total background.
void add(const TObject *pS, const TObject *pB, const TObject *ps, const TObject *pb)
Add objects with PDFs of signal and background.
void add(const TH1 &hs, const TH1 &hb)
Add histograms with PDFs of signal and background.
double fs
scaling factor signal strength
void configure(size_t N)
Configure lookup tables.
void add(const double s, const double b)
Add signal and background.
JPseudoExperiment()
Default constructor.