Jpp 20.0.0-72-g597b30bc9
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 343 of file JPseudoExperiment.hh.

Member Typedef Documentation

◆ fit_type

Constructor & Destructor Documentation

◆ JPseudoExperiment() [1/3]

JASTRONOMY::JPseudoExperiment::JPseudoExperiment ( )
inline

Default constructor.

Definition at line 351 of file JPseudoExperiment.hh.

352 {}

◆ 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 362 of file JPseudoExperiment.hh.

364 {
365 add(hs, hb);
366 }
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 378 of file JPseudoExperiment.hh.

382 {
383 add(hS, hB, hs, hb);
384 }

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 393 of file JPseudoExperiment.hh.

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

◆ 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 410 of file JPseudoExperiment.hh.

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

◆ 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 427 of file JPseudoExperiment.hh.

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

◆ 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 445 of file JPseudoExperiment.hh.

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

◆ 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 465 of file JPseudoExperiment.hh.

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

◆ 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 485 of file JPseudoExperiment.hh.

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

◆ 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 507 of file JPseudoExperiment.hh.

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

◆ 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 529 of file JPseudoExperiment.hh.

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

◆ add() [9/13]

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

Add signal and background.

Parameters
ssignal
bbackground

Definition at line 553 of file JPseudoExperiment.hh.

555 {
556 if (check(s, b)) {
557
558 cs.put(s);
559 cb.put(b);
560
561 aspera.put(s, b);
562
563 } else {
564
565 remnant.add(s, b, s, b);
566 }
567 }
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 578 of file JPseudoExperiment.hh.

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

◆ add() [11/13]

◆ getSignal()

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

Get total signal.

Returns
signal

Definition at line 617 of file JPseudoExperiment.hh.

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

◆ getBackground()

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

Get total background.

Returns
background

Definition at line 628 of file JPseudoExperiment.hh.

629 {
630 return cb.back() * this->fb;
631 }
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 640 of file JPseudoExperiment.hh.

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

◆ getAspera()

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

Get fit method.

Returns
fit

Implements JASTRONOMY::JPseudoExperiment_t.

Definition at line 656 of file JPseudoExperiment.hh.

657 {
658 return this->fit;
659 }

◆ 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 668 of file JPseudoExperiment.hh.

669 {
670 out.addSignal(aspera.getSignal());
671
672 const size_t ns = gRandom->Poisson(getSignal() * nuisance.signal ->get()); // number of signal events
673 const size_t nb = gRandom->Poisson(getBackground() * nuisance.background->get()); // number of background events
674
675 for (size_t i = ns; i != 0; --i) { out.push_back(aspera[cs.get_index(gRandom->Rndm())]); } // store distributed signal events
676 for (size_t i = nb; i != 0; --i) { out.push_back(aspera[cb.get_index(gRandom->Rndm())]); } // store distributed background events
677
678 return { ns, nb };
679 }
double getSignal() const
Get total signal strength.
Definition JAspera.hh:247
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 689 of file JPseudoExperiment.hh.

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

◆ configure()

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

Configure lookup tables.

Parameters
Nnumber of bins

Definition at line 742 of file JPseudoExperiment.hh.

743 {
744 cs.configure(N);
745 cb.configure(N);
746 }
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 757 of file JPseudoExperiment.hh.

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

◆ 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 788 of file JPseudoExperiment.hh.

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

◆ 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 if (( ps <= (1 - Q)) && (mu - mumin < precision) && (mumax - mu < precision)) return mu;
296
297 }
298 }
299 }
300
301 return 0.0;
302 }
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 312 of file JPseudoExperiment.hh.

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

◆ 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 909 of file JPseudoExperiment.hh.

◆ cb

cdf_type JASTRONOMY::JPseudoExperiment::cb
protected

CDF of background.

Definition at line 910 of file JPseudoExperiment.hh.

◆ aspera

JAspera JASTRONOMY::JPseudoExperiment::aspera
protected

pre-computed N/S values

Definition at line 912 of file JPseudoExperiment.hh.

◆ fs

double JASTRONOMY::JPseudoExperiment::fs = 1.0
protected

scaling factor signal strength

Definition at line 914 of file JPseudoExperiment.hh.

◆ fb

double JASTRONOMY::JPseudoExperiment::fb = 1.0
protected

scaling factor background strength

Definition at line 915 of file JPseudoExperiment.hh.

◆ fit

JAspera JASTRONOMY::JPseudoExperiment::fit
protected

fit

Definition at line 917 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: