Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
Functions
JPseudoExperimentCondNLLR.cc File Reference

Application for generating conditional Likelihood histograms of part of a dataset compared to the complete dataset. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <vector>
#include <map>
#include <exception>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "TRandom3.h"
#include "JAstronomy/JPseudoExperiment.hh"
#include "JAstronomy/JAspera.hh"
#include "JAstronomy/JAstronomyToolkit.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "JTools/JAbstractHistogram.hh"
#include "JROOT/JRandom.hh"
#include "Jeep/JContainer.hh"
#include "Jeep/JParser.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Application for generating conditional Likelihood histograms of part of a dataset compared to the complete dataset.

Used to generate trial factors with JTrialFactorsFromCondNLLR.cc

Author
mdejong fvazquezdesola

Definition in file JPseudoExperimentCondNLLR.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 179 of file JPseudoExperimentCondNLLR.cc.

180{
181 using namespace std;
182 using namespace JPP;
183
184 typedef JAbstractHistogram<double> histogram_type;
185
188 string outputFile;
189 size_t numberOfTests;
190 double Fs;
191 double Fb;
192 size_t M;
193 double SNR;
194 histogram_type X;
196 int debug;
197
198 try {
199
202
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"
207 << "\twhere <type> can be:" << get_keys(nuisance_helper) <<"\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"
213 << "\twhere <type> can be:" << get_keys(nuisance_helper) <<"\n."
214 << "\t Can be called repeatedly to add multiple datasets to this period");
215 zap['o'] = make_field(outputFile, "output file with histograms") = "CondNLLR.root";
216 zap['s'] = make_field(Fs, "signal strength");
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);
222 zap['S'] = make_field(seed) = 0;
223 zap['d'] = make_field(debug) = 1;
224
225 zap(argc, argv);
226 }
227 catch(const exception& error) {
228 FATAL(error.what() << endl);
229 }
230
231
232 seed.set(gRandom);
233 JExperiment::setSNR(SNR);
234
235
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);
240
241 TFile out(outputFile.c_str(), "recreate");
242
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());
249
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;
254 }
255
256 JAspera aspera;
259
260 for (const auto& px : pxg_1.px_vec) { px.run(aspera); }
261 result_1 = aspera();
262
263 for (const auto& px : pxg_2.px_vec) { px.run(aspera); }
264 result_A = aspera();
265
266 auto NLLR_1 = result_1.likelihood;
267 auto NLLR_A = result_A.likelihood;
268 if (NLLR_1 < 0) {
269 NLLR_1 = 0;
270 }
271 if (NLLR_A < 0) {
272 NLLR_A = 0;
273 }
274
276 if( result_1.signal * pxg_1.signal_weight > 1) {
279 }
280
281 }
282
283 cout << nexp_passfilter << " PEs pass the first period filter, out of " << numberOfTests << endl;
284
285 h2d_nllr.Write();
286 h2d_nllr_constr.Write();
287 out.Write();
288 out.Close();
289}
string outputFile
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
Definition JParser.hh:1698
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure to fit signal strength using likelihood ratio.
Definition JAspera.hh:24
Pseudo experiment using CDF for combined generation and likelihood evaluation.
virtual stats_type run(JAspera &out) const
Generate pseudo experiment and transfer values to fit method.
Template definition of random value generator.