33 struct experiment_type {
50 friend inline std::istream&
operator>>(std::istream& in, experiment_type& experiment)
52 return in >> experiment.HS
57 >> experiment.nuisance;
68 friend inline std::ostream&
operator<<(std::ostream& out,
const experiment_type& experiment)
70 return out << experiment.HS <<
' '
71 << experiment.HB <<
' '
72 << experiment.Hs <<
' '
73 << experiment.Hb <<
' '
74 << experiment.boost <<
' '
75 << experiment.nuisance;
90 printer(
const char*
const title,
103 friend inline std::ostream&
operator<<(std::ostream& out,
const printer& printer)
108 out << setw(16) << left << printer.title << right;
110 if (printer.ps != NULL) {
112 out <<
' ' << setw(16) << left << printer.ps->GetName() << right;
114 const TH1* h1 =
dynamic_cast<const TH1*
>(printer.ps);
117 out <<
' ' <<
FIXED(10,3) << h1->GetSumOfWeights();
125 const char*
const title;
133 struct experiment_group {
135 double signal_weight;
139 for (
const auto& setup : setup_vec) {
145 if (setup.boost != 1.) {
146 std::cout <<
"Boosting background and signal for following dataset by factor " << setup.boost << std::endl;
147 dynamic_cast<TH1*
>(pS)->Scale(setup.boost);
148 dynamic_cast<TH1*
>(pB)->Scale(setup.boost);
149 dynamic_cast<TH1*
>(ps)->Scale(setup.boost);
150 dynamic_cast<TH1*
>(pb)->Scale(setup.boost);
153 signal_weight +=
dynamic_cast<const TH1*
>(ps)->GetSumOfWeights();
154 STATUS(printer(
"Signal for generation:", pS) << std::endl);
155 STATUS(printer(
"Background for generation:", pB) << std::endl);
158 pi.nuisance = setup.nuisance;
163 px_vec.push_back(pi);
189 size_t numberOfTests;
204 "inputs for 1st data period: signal and background histograms for generation and evaluation,\n"
205 <<
"\texposure boost, and signal and background nuisances, provided as\n"
206 <<
"\t'<file>:<hgen_s name> <file>:<hgen_b name> <file>:<heval_s name> <file>:<heval_b name> <boost> <type_s> (values) <type_b> (values)' \n"
208 <<
"\t Can be called repeatedly to add multiple datasets to this period");
210 "inputs for 2nd data period: signal and background histograms for generation and evaluation,\n"
211 <<
"\texposure boost, and signal and background nuisances, provided as\n"
212 <<
"\t'<file>:<hgen_s name> <file>:<hgen_b name> <file>:<heval_s name> <file>:<heval_b name> <boost> <type_s> (values) <type_b> (values)' \n"
214 <<
"\t Can be called repeatedly to add multiple datasets to this period");
217 zap[
'b'] =
make_field(Fb,
"background strength") = 1.0;
218 zap[
'M'] =
make_field(M,
"lookup table for CDFs") = 0;
219 zap[
'R'] =
make_field(SNR,
"signal-to-noise ratio") = 0.0;
220 zap[
'n'] =
make_field(numberOfTests,
"number of tests / PEs");
221 zap[
'x'] =
make_field(X,
"x-axis for likelihood histogram") = histogram_type(200, 0, +20.0);
227 catch(
const exception& error) {
228 FATAL(error.what() << endl);
233 JExperiment::setSNR(SNR);
236 cout <<
"**Setting up 1st period**" << endl;
237 experiment_group pxg_1(setup_vec1, Fs, Fb, M);
238 cout <<
"**Setting up 2nd period**" << endl;
239 experiment_group pxg_2(setup_vec2, Fs, Fb, M);
243 TH2D h2d_nllr(
"h2d_nllr",
"Negative Log-Likelihood Ratio; NLLR 1st period; NLLR total",
244 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
245 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
246 TH2D h2d_nllr_constr(
"h2d_nllr_constr",
"Negative Log-Likelihood Ratio (filtered); NLLR 1st period; NLLR total",
247 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
248 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
250 size_t nexp_passfilter = 0;
251 for (
size_t nexp =0; nexp != numberOfTests; ++nexp) {
252 if (nexp%100000 == 0) {
253 cout <<
"Done " << nexp <<
" pseudo-experiments out of " << numberOfTests << endl;
260 for (
const auto& px : pxg_1.px_vec) { px.run(aspera); }
263 for (
const auto& px : pxg_2.px_vec) { px.run(aspera); }
275 h2d_nllr.Fill(NLLR_1, NLLR_A, 1./numberOfTests);
276 if( result_1.
signal * pxg_1.signal_weight > 1) {
278 h2d_nllr_constr.Fill(NLLR_1, NLLR_A, 1./numberOfTests);
283 cout << nexp_passfilter <<
" PEs pass the first period filter, out of " << numberOfTests << endl;
286 h2d_nllr_constr.Write();
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int main(int argc, char **argv)
Auxiliary class to handle file name, ROOT directory and object name.
Utility class to parse command line options.
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.
Auxiliary data structure for floating point format specification.
double signal
signal strength
double likelihood
likelihood
Auxiliary data structure to fit signal strength using likelihood ratio.
dictionary_type & getDictionary()
Get dictionary.
Pseudo experiment using CDF for combined generation and likelihood evaluation.
struct JASTRONOMY::JPseudoExperiment::parameters_type nuisance
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Template definition of random value generator.