Jpp 20.0.0-rc.6
the software that should make you happy
Loading...
Searching...
No Matches
JASTRONOMY::JPseudoExperiment_t Struct Referenceabstract

Auxiliary interface for pseudo experiment. More...

#include <JPseudoExperiment.hh>

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

Classes

struct  h0_type
 Auxiliary data structure for upper limit evaluations of background only pseudo experiments. More...
 
struct  result_type
 Result of combined pseudo experiment and fit. More...
 
struct  stats_type
 Statistics of pseudo experiment. More...
 

Public Types

typedef JAspera::fit_type fit_type
 fit type
 

Public Member Functions

virtual void set (const double fS, const double fB=1.0)=0
 Set scaling factors of signal and background strengths.
 
virtual JAsperagetAspera ()=0
 Get fit method.
 
virtual stats_type run (JAspera &out) const =0
 Generate pseudo experiment and transfer S/N values to fit method.
 
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.
 
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 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.
 

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.
 

Static Private Member Functions

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

Detailed Description

Auxiliary interface for pseudo experiment.

Definition at line 36 of file JPseudoExperiment.hh.

Member Typedef Documentation

◆ fit_type

Member Function Documentation

◆ set()

virtual void JASTRONOMY::JPseudoExperiment_t::set ( const double fS,
const double fB = 1.0 )
pure virtual

Set scaling factors of signal and background strengths.

Parameters
fSsignal strength
fBbackground strength

Implemented in JASTRONOMY::JGen2, and JASTRONOMY::JPseudoExperiment.

◆ getAspera()

virtual JAspera & JASTRONOMY::JPseudoExperiment_t::getAspera ( )
pure virtual

Get fit method.

Returns
fit

Implemented in JASTRONOMY::JGen2, and JASTRONOMY::JPseudoExperiment.

◆ run() [1/2]

virtual stats_type JASTRONOMY::JPseudoExperiment_t::run ( JAspera & out) const
pure virtual

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

Parameters
outoutput
Returns
result

Implemented in JASTRONOMY::JGen2, and JASTRONOMY::JPseudoExperiment.

◆ run() [2/2]

virtual stats_type JASTRONOMY::JPseudoExperiment_t::run ( JAspera & out,
const size_t nb ) const
pure virtual

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

Parameters
outoutput
nbnumber of background events
Returns
result

Implemented in JASTRONOMY::JGen2, and JASTRONOMY::JPseudoExperiment.

◆ operator()() [1/5]

result_type JASTRONOMY::JPseudoExperiment_t::operator() ( )
inline

Generate pseudo experiment and fit signal strength.

Returns
result

Definition at line 154 of file JPseudoExperiment.hh.

155 {
156 JAspera& aspera = getAspera();
157
158 // reset
159
160 aspera.clear();
161 aspera.setSignal(0.0);
162
163 return { run(aspera), aspera() };
164 }
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)
inline

Generate background only pseudo experiment and fit signal strength.

Parameters
nbnumber of background events
Returns
result

Definition at line 173 of file JPseudoExperiment.hh.

174 {
175 JAspera& aspera = getAspera();
176
177 // reset
178
179 aspera.clear();
180 aspera.setSignal(0.0);
181
182 return { run(aspera, nb), aspera() };
183 }

◆ operator()() [3/5]

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

Run pseudo experiments using given storage.

Parameters
storagestorage

Definition at line 191 of file JPseudoExperiment.hh.

192 {
193 for (auto& i : storage) {
194 i = (*this)();
195 }
196 }

◆ operator()() [4/5]

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

Run pseudo experiments using given storage.

Parameters
pmpointer to data member of result
storagestorage

Definition at line 206 of file JPseudoExperiment.hh.

207 {
208 for (auto& i : storage) {
209 i = (*this)().*pm;
210 }
211 }

◆ operator()() [5/5]

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

Run pseudo experiments using given storage.

Parameters
pmpointer to data member of result
storagestorage

Definition at line 221 of file JPseudoExperiment.hh.

222 {
223 (*this)(static_cast<JValue_t result_type::*>(pm), storage);
224 }

◆ getProbabilityForUpperLimit()

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

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

237 {
238 size_t ns = 0;
239
240 for (size_t i = 0; i != nx; ++i) {
241
242 JAspera aspera;
243
244 this->run(aspera);
245
246 if (ps <= std::numeric_limits<double>::min()) {
247
248 if (aspera().signal <= ps) {
249 ns += 1;
250 }
251
252 } else if (aspera.getTestStatisticForUpperLimit(ps) > ts) {
253 ns += 1;
254 }
255 }
256
257 return (double) ns / (double) nx;
258 }

◆ getSNR()

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

Get minimal signa-to-noise ratio.

Returns
signa-to-noise ratio.

Definition at line 32 of file JExperiment.hh.

33 {
34 return get_snr();
35 }
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 43 of file JExperiment.hh.

44 {
45 get_snr() = value;
46 }

◆ check() [1/5]

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

Check validity of signal and background.

Parameters
ssignal
bbackground
Returns
true if signal and backgroud are valid; else false

Definition at line 56 of file JExperiment.hh.

57 {
58 return (s > 0.0 && b > 0.0 && s/b >= getSNR());
59 }
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 69 of file JExperiment.hh.

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

◆ 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 83 of file JExperiment.hh.

84 {
85 return check(ha.GetXaxis(), hb.GetXaxis());
86 }
static bool check(const double s, const double b)
Check validity of signal and background.

◆ 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 96 of file JExperiment.hh.

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

◆ 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 110 of file JExperiment.hh.

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

◆ get_snr()

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

Get minimal signa-to-noise ratio.

Returns
signa-to-noise ratio.

Definition at line 123 of file JExperiment.hh.

124 {
125 static double value = 0.0;
126
127 return value;
128 }

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