1#ifndef __JASTRONOMY__JPSEUDOEXPERIMENT__
2#define __JASTRONOMY__JPSEUDOEXPERIMENT__
102 return {
run(aspera), aspera() };
113 for (
auto& i : storage) {
125 template<
class T,
class JValue_t>
128 for (
auto& i : storage) {
140 template<
class T,
class JValue_t>
143 (*this)(
static_cast<JValue_t
result_type::*
>(pm), storage);
221 if (
add<TH3>(pS, pB, ps, pb)) {
return; }
222 if (
add<TH2>(pS, pB, ps, pb)) {
return; }
223 if (
add<TH1>(pS, pB, ps, pb)) {
return; }
236 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
237 add(hs.GetBinContent(ix),
238 hb.GetBinContent(ix));
256 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
257 add(hS.GetBinContent(ix),
258 hB.GetBinContent(ix),
259 hs.GetBinContent(ix),
260 hb.GetBinContent(ix));
274 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
275 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
276 add(hs.GetBinContent(ix, iy),
277 hb.GetBinContent(ix, iy));
296 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
297 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
298 add(hS.GetBinContent(ix, iy),
299 hB.GetBinContent(ix, iy),
300 hs.GetBinContent(ix, iy),
301 hb.GetBinContent(ix, iy));
316 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
317 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
318 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
319 add(hs.GetBinContent(ix, iy, iz),
320 hb.GetBinContent(ix, iy, iz));
340 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
341 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
342 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
343 add(hS.GetBinContent(ix, iy, iz),
344 hB.GetBinContent(ix, iy, iz),
345 hs.GetBinContent(ix, iy, iz),
346 hb.GetBinContent(ix, iy, iz));
403 return cs.back() * this->
fs;
414 return cb.back() * this->
fb;
424 void set(
const double fS,
const double fB)
459 for (
size_t i = ns; i != 0; --i) { out.push_back(
aspera[
cs.
get_index(gRandom->Rndm())]); }
460 for (
size_t i = nb; i != 0; --i) { out.push_back(
aspera[
cb.
get_index(gRandom->Rndm())]); }
480 return in >> parameters.
signal
494 return out << parameters.
signal <<
' '
515 if (
dynamic_cast<const H_t*
>(ps) != NULL &&
516 dynamic_cast<const H_t*
>(pb) != NULL) {
518 const H_t& hs =
dynamic_cast<const H_t&
>(*ps);
519 const H_t& hb =
dynamic_cast<const H_t&
>(*pb);
548 if (
dynamic_cast<const H_t*
>(pS) != NULL &&
549 dynamic_cast<const H_t*
>(pB) != NULL &&
550 dynamic_cast<const H_t*
>(ps) != NULL &&
551 dynamic_cast<const H_t*
>(pb) != NULL) {
553 const H_t& hS =
dynamic_cast<const H_t&
>(*pS);
554 const H_t& hB =
dynamic_cast<const H_t&
>(*pB);
555 const H_t& hs =
dynamic_cast<const H_t&
>(*ps);
556 const H_t& hb =
dynamic_cast<const H_t&
>(*pb);
584 const double value = this->back() * rv;
587 size_t count = this->size();
589 for (
size_t i, step; count != 0; ) {
594 if ((*
this)[i] < value) {
616 this->push_back(this->back() + x);
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure to fit signal strength using likelihood ratio.
void addSignal(const double wS)
Add signal strength.
double getSignal() const
Get total signal strength.
void setSignal(const double wS)
Set signal strength.
void put(const double s, const double b)
Put signal and background to list of pre-computed N/S values.
Auxiliary base class for experiment.
static bool check(const double s, const double b)
Check validity of signal and background.
Auxiliary data structure for CDF.
void put(const double x)
Put given value.
size_t get_index(const double rv) const
Get index corresponding to given random value.
friend std::ostream & operator<<(std::ostream &out, const parameters_type ¶meters)
Write parameters to output stream.
friend std::istream & operator>>(std::istream &in, parameters_type ¶meters)
Read parameters from input stream.
Result of combined pseudo experiment and fit.
Statistics of pseudo experiment.
size_t ns
number of generated signal events
size_t nb
number of generated background events
stats_type & operator+=(const stats_type &px)
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.
void operator()(JValue_t result_type::*pm, std::vector< T > &storage)
Run pseudo experiments using given storage.
void operator()(std::vector< result_type > &storage)
Run pseudo experiments using given storage.
virtual stats_type run(JAspera &out) const =0
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
cdf_type cs
CDF of signal.
virtual stats_type run(JAspera &out) const
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.
void set(const double fS, const double fB)
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 add(const double s, const double b)
Add signal and background.
JPseudoExperiment()
Default constructor.