Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JASTRONOMY::JPseudoExperiment Struct Reference

Pseudo experiment using CDF for combined generation and likelihood evaluation. More...

#include <JPseudoExperiment.hh>

Inheritance diagram for JASTRONOMY::JPseudoExperiment:
JASTRONOMY::JPseudoExperiment_t JASTRONOMY::JExperiment

Classes

struct  cdf_type
 Auxiliary data structure for CDF. More...
 
struct  parameters_type
 Nuisance parameters. More...
 
struct  remnant_type
 

Public Types

typedef JAspera::fit_type fit_type
 fit type
 

Public Member Functions

 JPseudoExperiment ()
 Default constructor.
 
template<class H_t >
 JPseudoExperiment (const H_t &hs, const H_t &hb)
 Constructor.
 
template<class H_t >
 JPseudoExperiment (const H_t &hS, const H_t &hB, const H_t &hs, const H_t &hb)
 Constructor.
 
void add (const TObject *ps, const TObject *pb)
 Add objects with PDFs of signal and 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.
 
void add (const TH1 &hS, const TH1 &hB, const TH1 &hs, const TH1 &hb)
 Add histograms with PDFs of signal and background.
 
void add (const TH2 &hs, const TH2 &hb)
 Add histograms with PDFs of signal and background.
 
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.
 
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 double s, const double b)
 Add signal and background.
 
void add (const double S, const double B, const double s, const double b)
 Add signal and background.
 
void add ()
 Add remnant signal and background.
 
double getSignal () const
 Get total signal.
 
double getBackground () const
 Get total background.
 
virtual void set (const double fS, const double fB=1.0) override
 Set scaling factors of signal and background strengths.
 
virtual JAsperagetAspera () override
 Get fit method.
 
virtual stats_type run (JAspera &out) const
 Generate pseudo experiment and transfer values to fit method.
 
virtual stats_type run (JAspera &out, const size_t nb) const
 Generate background only pseudo experiment and transfer S/N values to fit method.
 
void configure (size_t N)
 Configure lookup tables.
 
result_type operator() ()
 Generate pseudo experiment and fit signal strength.
 
result_type operator() (const size_t nb)
 Generate background only pseudo experiment and fit signal strength.
 
void operator() (std::vector< result_type > &storage)
 Run pseudo experiments using given storage.
 
template<class T , class JValue_t >
void operator() (JValue_t result_type::*pm, std::vector< T > &storage)
 Run pseudo experiments using given storage.
 
template<class T , class JValue_t >
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.
 

Static Public Member Functions

static double getSNR ()
 Get minimal signa-to-noise ratio.
 
static void setSNR (const double value)
 Set minimal signa-to-noise ratio.
 
static bool check (const double s, const double b)
 Check validity of signal and background.
 
static bool check (const TAxis *ha, const TAxis *hb)
 Check histogram bins.
 
static bool check (const TH1 &ha, const TH1 &hb)
 Check histogram bins.
 
static bool check (const TH2 &ha, const TH2 &hb)
 Check histogram bins.
 
static bool check (const TH3 &ha, const TH3 &hb)
 Check histogram bins.
 

Public Attributes

struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
 

Static Public Attributes

static constexpr double MINIMAL_SIGNAL_STRENGTH = 1.0e-10
 
static constexpr double MAXIMAL_SIGNAL_STRENGTH = 1.0e+10
 

Protected Member Functions

template<class H_t >
bool add (const TObject *ps, const TObject *pb)
 Add objects with PDF of signal and background.
 
template<class H_t >
bool add (const TObject *pS, const TObject *pB, const TObject *ps, const TObject *pb)
 Add objects with PDF of signal and background.
 
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 upper limit.
 

Protected Attributes

cdf_type cs
 CDF of signal.
 
cdf_type cb
 CDF of background.
 
JAspera aspera
 pre-computed N/S values
 
double fs = 1.0
 scaling factor signal strength
 
double fb = 1.0
 scaling factor background strength
 
JAspera fit
 fit
 
struct JASTRONOMY::JPseudoExperiment::remnant_type remnant
 

Static Private Member Functions

static double & get_snr ()
 Get minimal signa-to-noise ratio.
 

Detailed Description

Pseudo experiment using CDF for combined generation and likelihood evaluation.

Definition at line 345 of file JPseudoExperiment.hh.

Member Typedef Documentation

◆ fit_type

Constructor & Destructor Documentation

◆ JPseudoExperiment() [1/3]

JASTRONOMY::JPseudoExperiment::JPseudoExperiment ( )
inline

Default constructor.

Definition at line 353 of file JPseudoExperiment.hh.

354 {}

◆ JPseudoExperiment() [2/3]

template<class H_t >
JASTRONOMY::JPseudoExperiment::JPseudoExperiment ( const H_t & hs,
const H_t & hb )
inline

Constructor.

Parameters
hshistogram with PDF of signal
hbhistogram with PDF of background

Definition at line 364 of file JPseudoExperiment.hh.

366 {
367 add(hs, hb);
368 }
void add()
Add remnant signal and background.

◆ JPseudoExperiment() [3/3]

template<class H_t >
JASTRONOMY::JPseudoExperiment::JPseudoExperiment ( const H_t & hS,
const H_t & hB,
const H_t & hs,
const H_t & hb )
inline

Constructor.

Parameters
hShistogram with PDF for generation of signal
hBhistogram with PDF for generation of background
hshistogram with PDF for evaluation of signal
hbhistogram with PDF for evaluation of background

Definition at line 380 of file JPseudoExperiment.hh.

384 {
385 add(hS, hB, hs, hb);
386 }

Member Function Documentation

◆ add() [1/13]

void JASTRONOMY::JPseudoExperiment::add ( const TObject * ps,
const TObject * pb )
inline

Add objects with PDFs of signal and background.

Parameters
pspointer to object with PDF of signal
pbpointer to object with PDF of background

Definition at line 395 of file JPseudoExperiment.hh.

397 {
398 if (add<TH3>(ps, pb)) { return; }
399 if (add<TH2>(ps, pb)) { return; }
400 if (add<TH1>(ps, pb)) { return; }
401 }

◆ add() [2/13]

void JASTRONOMY::JPseudoExperiment::add ( const TObject * pS,
const TObject * pB,
const TObject * ps,
const TObject * pb )
inline

Add objects with PDFs of signal and background.

Parameters
pSpointer to object with PDF for generation of signal
pBpointer to object with PDF for generation of background
pspointer to object with PDF for evaluation of signal
pbpointer to object with PDF for evaluation of background

Definition at line 412 of file JPseudoExperiment.hh.

416 {
417 if (add<TH3>(pS, pB, ps, pb)) { return; }
418 if (add<TH2>(pS, pB, ps, pb)) { return; }
419 if (add<TH1>(pS, pB, ps, pb)) { return; }
420 }

◆ add() [3/13]

void JASTRONOMY::JPseudoExperiment::add ( const TH1 & hs,
const TH1 & hb )
inline

Add histograms with PDFs of signal and background.

Parameters
hshistogram with PDF of signal
hbhistogram with PDF of background

Definition at line 429 of file JPseudoExperiment.hh.

431 {
432 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
433 add(hs.GetBinContent(ix),
434 hb.GetBinContent(ix));
435 }
436 }

◆ add() [4/13]

void JASTRONOMY::JPseudoExperiment::add ( const TH1 & hS,
const TH1 & hB,
const TH1 & hs,
const TH1 & hb )
inline

Add histograms with PDFs of signal and background.

Parameters
hShistogram with PDF for generation of signal
hBhistogram with PDF for generation of background
hshistogram with PDF for evaluation of signal
hbhistogram with PDF for evaluation of background

Definition at line 447 of file JPseudoExperiment.hh.

451 {
452 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
453 add(hS.GetBinContent(ix),
454 hB.GetBinContent(ix),
455 hs.GetBinContent(ix),
456 hb.GetBinContent(ix));
457 }
458 }

◆ add() [5/13]

void JASTRONOMY::JPseudoExperiment::add ( const TH2 & hs,
const TH2 & hb )
inline

Add histograms with PDFs of signal and background.

Parameters
hshistogram with PDF of signal
hbhistogram with PDF of background

Definition at line 467 of file JPseudoExperiment.hh.

469 {
470 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
471 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
472 add(hs.GetBinContent(ix, iy),
473 hb.GetBinContent(ix, iy));
474 }
475 }
476 }

◆ add() [6/13]

void JASTRONOMY::JPseudoExperiment::add ( const TH2 & hS,
const TH2 & hB,
const TH2 & hs,
const TH2 & hb )
inline

Add histograms with PDFs of signal and background.

Parameters
hShistogram with PDF for generation of signal
hBhistogram with PDF for generation of background
hshistogram with PDF for evaluation of signal
hbhistogram with PDF for evaluation of background

Definition at line 487 of file JPseudoExperiment.hh.

491 {
492 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
493 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
494 add(hS.GetBinContent(ix, iy),
495 hB.GetBinContent(ix, iy),
496 hs.GetBinContent(ix, iy),
497 hb.GetBinContent(ix, iy));
498 }
499 }
500 }

◆ add() [7/13]

void JASTRONOMY::JPseudoExperiment::add ( const TH3 & hs,
const TH3 & hb )
inline

Add histograms with PDFs of signal and background.

Parameters
hshistogram with PDF of signal
hbhistogram with PDF of background

Definition at line 509 of file JPseudoExperiment.hh.

511 {
512 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
513 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
514 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
515 add(hs.GetBinContent(ix, iy, iz),
516 hb.GetBinContent(ix, iy, iz));
517 }
518 }
519 }
520 }

◆ add() [8/13]

void JASTRONOMY::JPseudoExperiment::add ( const TH3 & hS,
const TH3 & hB,
const TH3 & hs,
const TH3 & hb )
inline

Add histograms with PDFs of signal and background.

Parameters
hShistogram with PDF for generation of signal
hBhistogram with PDF for generation of background
hshistogram with PDF for evaluation of signal
hbhistogram with PDF for evaluation of background

Definition at line 531 of file JPseudoExperiment.hh.

535 {
536 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
537 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
538 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
539 add(hS.GetBinContent(ix, iy, iz),
540 hB.GetBinContent(ix, iy, iz),
541 hs.GetBinContent(ix, iy, iz),
542 hb.GetBinContent(ix, iy, iz));
543 }
544 }
545 }
546 }

◆ add() [9/13]

void JASTRONOMY::JPseudoExperiment::add ( const double s,
const double b )
inline

Add signal and background.

Parameters
ssignal
bbackground

Definition at line 555 of file JPseudoExperiment.hh.

557 {
558 if (check(s, b)) {
559
560 cs.put(s);
561 cb.put(b);
562
563 aspera.put(s, b);
564
565 } else {
566
567 remnant.add(s, b, s, b);
568 }
569 }
void put(const double s, const double b)
Put signal and background to list of pre-computed N/S values.
Definition JAspera.hh:44
static bool check(const double s, const double b)
Check validity of signal and background.
void put(const double x)
Put given value.
void add(const double S, const double B, const double s, const double b)
cdf_type cb
CDF of background.
JAspera aspera
pre-computed N/S values
struct JASTRONOMY::JPseudoExperiment::remnant_type remnant

◆ add() [10/13]

void JASTRONOMY::JPseudoExperiment::add ( const double S,
const double B,
const double s,
const double b )
inline

Add signal and background.

Parameters
Ssignal for generation
Bbackground for generation
ssignal for evaluation
bbackground for evaluation

Definition at line 580 of file JPseudoExperiment.hh.

584 {
585 if (//check(S, B) &&
586 check(s, b)) {
587
588 cs.put(S);
589 cb.put(B);
590
591 aspera.put(s, b);
592
593 } else {
594
595 remnant.add(S, B, s, b);
596 }
597 }

◆ add() [11/13]

◆ getSignal()

double JASTRONOMY::JPseudoExperiment::getSignal ( ) const
inline

Get total signal.

Returns
signal

Definition at line 619 of file JPseudoExperiment.hh.

620 {
621 return cs.back() * this->fs;
622 }
double fs
scaling factor signal strength

◆ getBackground()

double JASTRONOMY::JPseudoExperiment::getBackground ( ) const
inline

Get total background.

Returns
background

Definition at line 630 of file JPseudoExperiment.hh.

631 {
632 return cb.back() * this->fb;
633 }
double fb
scaling factor background strength

◆ set()

virtual void JASTRONOMY::JPseudoExperiment::set ( const double fS,
const double fB = 1.0 )
inlineoverridevirtual

Set scaling factors of signal and background strengths.

Parameters
fSsignal strength
fBbackground strength

Implements JASTRONOMY::JPseudoExperiment_t.

Definition at line 642 of file JPseudoExperiment.hh.

643 {
644 for (auto& i : aspera) {
645 i *= fB / this->fb;
646 }
647
648 this->fs = fS;
649 this->fb = fB;
650 }

◆ getAspera()

virtual JAspera & JASTRONOMY::JPseudoExperiment::getAspera ( )
inlineoverridevirtual

Get fit method.

Returns
fit

Implements JASTRONOMY::JPseudoExperiment_t.

Definition at line 658 of file JPseudoExperiment.hh.

659 {
660 return this->fit;
661 }

◆ run() [1/2]

virtual stats_type JASTRONOMY::JPseudoExperiment::run ( JAspera & out) const
inlinevirtual

Generate pseudo experiment and transfer values to fit method.

Parameters
outoutput
Returns
result

Implements JASTRONOMY::JPseudoExperiment_t.

Definition at line 670 of file JPseudoExperiment.hh.

671 {
672 out.addSignal(aspera.getSignal());
673
674 const size_t ns = gRandom->Poisson(getSignal() * nuisance.signal ->get()); // number of signal events
675 const size_t nb = gRandom->Poisson(getBackground() * nuisance.background->get()); // number of background events
676
677 for (size_t i = ns; i != 0; --i) { out.push_back(aspera[cs.get_index(gRandom->Rndm())]); } // store distributed signal events
678 for (size_t i = nb; i != 0; --i) { out.push_back(aspera[cb.get_index(gRandom->Rndm())]); } // store distributed background events
679
680 return { ns, nb };
681 }
double getSignal() const
Get total signal strength.
Definition JAspera.hh:349
size_t get_index(const double rv, const bool option=false) const
Get index corresponding to given random value.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
double getSignal() const
Get total signal.
double getBackground() const
Get total background.

◆ run() [2/2]

virtual stats_type JASTRONOMY::JPseudoExperiment::run ( JAspera & out,
const size_t nb ) const
inlinevirtual

Generate background only pseudo experiment and transfer S/N values to fit method.

Parameters
outoutput
nbnumber of background events
Returns
result

Implements JASTRONOMY::JPseudoExperiment_t.

Definition at line 691 of file JPseudoExperiment.hh.

692 {
693 out.addSignal(aspera.getSignal());
694
695 for (size_t i = nb; i != 0; --i) { out.push_back(aspera[cb.get_index(gRandom->Rndm())]); } // store distributed background events
696
697 return { 0, nb };
698 }

◆ configure()

void JASTRONOMY::JPseudoExperiment::configure ( size_t N)
inline

Configure lookup tables.

Parameters
Nnumber of bins

Definition at line 744 of file JPseudoExperiment.hh.

745 {
746 cs.configure(N);
747 cb.configure(N);
748 }
void configure(size_t N)
Configure lookup table to substitute binary search.

◆ add() [12/13]

template<class H_t >
bool JASTRONOMY::JPseudoExperiment::add ( const TObject * ps,
const TObject * pb )
inlineprotected

Add objects with PDF of signal and background.

Parameters
pspointer to object with PDF of signal
pbpointer to object with PDF of background
Returns
true if added; else false

Definition at line 759 of file JPseudoExperiment.hh.

761 {
762 if (dynamic_cast<const H_t*>(ps) != NULL &&
763 dynamic_cast<const H_t*>(pb) != NULL) {
764
765 const H_t& hs = dynamic_cast<const H_t&>(*ps);
766 const H_t& hb = dynamic_cast<const H_t&>(*pb);
767
768 if (check(hs, hb)) {
769
770 add(hs, hb);
771
772 return true;
773 }
774 }
775
776 return false;
777 }

◆ add() [13/13]

template<class H_t >
bool JASTRONOMY::JPseudoExperiment::add ( const TObject * pS,
const TObject * pB,
const TObject * ps,
const TObject * pb )
inlineprotected

Add objects with PDF of signal and background.

Parameters
pSpointer to object with PDF for generation of signal
pBpointer to object with PDF for generation of background
pspointer to object with PDF for evaluation of signal
pbpointer to object with PDF for evaluation of background
Returns
true if added; else false

Definition at line 790 of file JPseudoExperiment.hh.

794 {
795 if (dynamic_cast<const H_t*>(pS) != NULL &&
796 dynamic_cast<const H_t*>(pB) != NULL &&
797 dynamic_cast<const H_t*>(ps) != NULL &&
798 dynamic_cast<const H_t*>(pb) != NULL) {
799
800 const H_t& hS = dynamic_cast<const H_t&>(*pS);
801 const H_t& hB = dynamic_cast<const H_t&>(*pB);
802 const H_t& hs = dynamic_cast<const H_t&>(*ps);
803 const H_t& hb = dynamic_cast<const H_t&>(*pb);
804
805 if (check(hS, hB) && check(hB, hs) && check(hs, hb)) {
806
807 add(hS, hB, hs, hb);
808
809 return true;
810 }
811 }
812
813 return false;
814 }

◆ operator()() [1/5]

result_type JASTRONOMY::JPseudoExperiment_t::operator() ( )
inlineinherited

Generate pseudo experiment and fit signal strength.

Returns
result

Definition at line 115 of file JPseudoExperiment.hh.

116 {
117 JAspera& aspera = getAspera();
118
119 // reset
120
121 aspera.clear();
122 aspera.setSignal(0.0);
123
124 return { run(aspera), aspera() };
125 }
virtual JAspera & getAspera()=0
Get fit method.
virtual stats_type run(JAspera &out) const =0
Generate pseudo experiment and transfer S/N values to fit method.

◆ operator()() [2/5]

result_type JASTRONOMY::JPseudoExperiment_t::operator() ( const size_t nb)
inlineinherited

Generate background only pseudo experiment and fit signal strength.

Parameters
nbnumber of background events
Returns
result

Definition at line 134 of file JPseudoExperiment.hh.

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 }

◆ operator()() [3/5]

void JASTRONOMY::JPseudoExperiment_t::operator() ( std::vector< result_type > & storage)
inlineinherited

Run pseudo experiments using given storage.

Parameters
storagestorage

Definition at line 152 of file JPseudoExperiment.hh.

153 {
154 for (auto& i : storage) {
155 i = (*this)();
156 }
157 }

◆ operator()() [4/5]

template<class T , class JValue_t >
void JASTRONOMY::JPseudoExperiment_t::operator() ( JValue_t result_type::* pm,
std::vector< T > & storage )
inlineinherited

Run pseudo experiments using given storage.

Parameters
pmpointer to data member of result
storagestorage

Definition at line 167 of file JPseudoExperiment.hh.

168 {
169 for (auto& i : storage) {
170 i = (*this)().*pm;
171 }
172 }

◆ operator()() [5/5]

template<class T , class JValue_t >
void JASTRONOMY::JPseudoExperiment_t::operator() ( JValue_t JAspera::fit_type::* pm,
std::vector< T > & storage )
inlineinherited

Run pseudo experiments using given storage.

Parameters
pmpointer to data member of result
storagestorage

Definition at line 182 of file JPseudoExperiment.hh.

183 {
184 (*this)(static_cast<JValue_t result_type::*>(pm), storage);
185 }

◆ getSignalStrengthForUpperLimit()

double JASTRONOMY::JPseudoExperiment_t::getSignalStrengthForUpperLimit ( const JAspera & aspera,
const double Q,
const size_t numberOfTests,
const double precision = 1.0e-4 )
inlineinherited

Get signal strength given result of experiment and probability of upper limit.

Parameters
asperaresult of experiment
Qprobability
numberOfTestsnumber of tests
precisionprecision
Returns
signal strength

Definition at line 201 of file JPseudoExperiment.hh.

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 // we have slight overcoverage and can't reach requested CL precisely
295
296 if (ps <= 1.0 - Q && mumax - mumin < precision) {
297 return mu;
298 }
299 }
300 }
301 }
302
303 return 0.0;
304 }
const int n
Definition JPolint.hh:791
static constexpr double MINIMAL_SIGNAL_STRENGTH
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

◆ getProbabilityForUpperLimit()

double JASTRONOMY::JPseudoExperiment_t::getProbabilityForUpperLimit ( const double ps,
const double ts,
const size_t nx ) const
inlineprotectedinherited

Get probability for given pseudo experiment and signal strength to exceed minimal test statistic for upper limit.

Parameters
pssignal strength
tstest statistic
nxnumber of pseudo experiments

Definition at line 314 of file JPseudoExperiment.hh.

317 {
318 size_t ns = 0;
319
320 for (size_t i = 0; i != nx; ++i) {
321
322 JAspera aspera;
323
324 this->run(aspera);
325
326 if (ps <= std::numeric_limits<double>::min()) {
327
328 if (aspera().signal <= ps) {
329 ns += 1;
330 }
331
332 } else if (aspera.getTestStatisticForUpperLimit(ps) > ts) {
333 ns += 1;
334 }
335 }
336
337 return (double) ns / (double) nx;
338 }

◆ getSNR()

static double JASTRONOMY::JExperiment::getSNR ( )
inlinestaticinherited

Get minimal signa-to-noise ratio.

Returns
signa-to-noise ratio.

Definition at line 33 of file JExperiment.hh.

34 {
35 return get_snr();
36 }
static double & get_snr()
Get minimal signa-to-noise ratio.

◆ setSNR()

static void JASTRONOMY::JExperiment::setSNR ( const double value)
inlinestaticinherited

Set minimal signa-to-noise ratio.

Parameters
valuesigna-to-noise ratio.

Definition at line 44 of file JExperiment.hh.

45 {
46 get_snr() = value;
47 }

◆ check() [1/5]

static bool JASTRONOMY::JExperiment::check ( const double s,
const double b )
inlinestaticinherited

Check validity of signal and background.

Parameters
ssignal
bbackground compare significance expectation for 1 bin with cut value
Returns
true if signal and backgroud are valid; else false

Definition at line 58 of file JExperiment.hh.

59 {
60 return (s > 0.0 && b > 0.0 && (s+s*s)/(b+b*b) >= getSNR()); //E(S^2) / E(B^2) for Poisson distribution
61 }
static double getSNR()
Get minimal signa-to-noise ratio.

◆ check() [2/5]

static bool JASTRONOMY::JExperiment::check ( const TAxis * ha,
const TAxis * hb )
inlinestaticinherited

Check histogram bins.

Parameters
hahistogram axis
hbhistogram axis
Returns
true if same binning; else false

Definition at line 71 of file JExperiment.hh.

72 {
73 return (ha->GetNbins() == hb->GetNbins() &&
74 ha->GetXmin() == hb->GetXmin() &&
75 ha->GetXmax() == hb->GetXmax());
76 }

◆ check() [3/5]

static bool JASTRONOMY::JExperiment::check ( const TH1 & ha,
const TH1 & hb )
inlinestaticinherited

Check histogram bins.

Parameters
hahistogram
hbhistogram
Returns
true if same binning; else false

Definition at line 85 of file JExperiment.hh.

86 {
87 return check(ha.GetXaxis(), hb.GetXaxis());
88 }

◆ check() [4/5]

static bool JASTRONOMY::JExperiment::check ( const TH2 & ha,
const TH2 & hb )
inlinestaticinherited

Check histogram bins.

Parameters
hahistogram
hbhistogram
Returns
true if same binning; else false

Definition at line 98 of file JExperiment.hh.

99 {
100 return (check(ha.GetXaxis(), hb.GetXaxis()) &&
101 check(ha.GetYaxis(), hb.GetYaxis()));
102 }

◆ check() [5/5]

static bool JASTRONOMY::JExperiment::check ( const TH3 & ha,
const TH3 & hb )
inlinestaticinherited

Check histogram bins.

Parameters
hahistogram
hbhistogram
Returns
true if same binning; else false

Definition at line 112 of file JExperiment.hh.

113 {
114 return (check(ha.GetXaxis(), hb.GetXaxis()) &&
115 check(ha.GetYaxis(), hb.GetYaxis()) &&
116 check(ha.GetZaxis(), hb.GetZaxis()));
117 }

◆ get_snr()

static double & JASTRONOMY::JExperiment::get_snr ( )
inlinestaticprivateinherited

Get minimal signa-to-noise ratio.

Returns
signa-to-noise ratio.

Definition at line 125 of file JExperiment.hh.

126 {
127 static double value = 0.0;
128
129 return value;
130 }

Member Data Documentation

◆ nuisance

struct JASTRONOMY::JPseudoExperiment::parameters_type JASTRONOMY::JPseudoExperiment::nuisance

◆ cs

cdf_type JASTRONOMY::JPseudoExperiment::cs
protected

CDF of signal.

Definition at line 911 of file JPseudoExperiment.hh.

◆ cb

cdf_type JASTRONOMY::JPseudoExperiment::cb
protected

CDF of background.

Definition at line 912 of file JPseudoExperiment.hh.

◆ aspera

JAspera JASTRONOMY::JPseudoExperiment::aspera
protected

pre-computed N/S values

Definition at line 914 of file JPseudoExperiment.hh.

◆ fs

double JASTRONOMY::JPseudoExperiment::fs = 1.0
protected

scaling factor signal strength

Definition at line 916 of file JPseudoExperiment.hh.

◆ fb

double JASTRONOMY::JPseudoExperiment::fb = 1.0
protected

scaling factor background strength

Definition at line 917 of file JPseudoExperiment.hh.

◆ fit

JAspera JASTRONOMY::JPseudoExperiment::fit
protected

fit

Definition at line 919 of file JPseudoExperiment.hh.

◆ remnant

struct JASTRONOMY::JPseudoExperiment::remnant_type JASTRONOMY::JPseudoExperiment::remnant
protected

◆ MINIMAL_SIGNAL_STRENGTH

double JASTRONOMY::JPseudoExperiment_t::MINIMAL_SIGNAL_STRENGTH = 1.0e-10
staticconstexprinherited

Definition at line 188 of file JPseudoExperiment.hh.

◆ MAXIMAL_SIGNAL_STRENGTH

double JASTRONOMY::JPseudoExperiment_t::MAXIMAL_SIGNAL_STRENGTH = 1.0e+10
staticconstexprinherited

Definition at line 189 of file JPseudoExperiment.hh.


The documentation for this struct was generated from the following file: