1#ifndef __JSUPERNOVA_JLIGHTCURVEBACKGROUNDGENERATOR__
2#define __JSUPERNOVA_JLIGHTCURVEBACKGROUNDGENERATOR__
44 int n = in->GetNbinsX();
48 for (
int i = 0; i <
n; i++) {
49 out[i] = in->GetBinContent(i + 1);
91 TString
rt_tag =
".RT_DET_SUM";
92 TString
nc_tag =
".NC_DET_SUM";
101 const TString tag(key->GetName());
104 if (tag.EndsWith(
rt_tag)) {
107 TString
run_tag = TString(tag, tag.Length() -
rt_tag.Length());
124 for (
int i = 0; i <
n; i++) {
128 for (
int j = 100 * i;
j < 100 * (i + 1);
j++) {
139 RT2D->SetDirectory(0);
200 int k =
rnd->Integer(
rt.size());
206 for (
int i = 0; i <
genRatio; i++) {
231 for (
unsigned i = 0; i < out[0].size(); i++) {
233 double count =
rnd->Poisson(mu);
261 int offset =
rnd->Integer(100);
263 for (
int i = 0; i <
genRatio; i++) {
299 for (
int i = 0; i <
genRatio; i++) {
332 for (
int i = 0; i <
genRatio; i++) {
352 const int n = in.size();
356 for (
int i = 0; i <
n; i++) {
371 if (
rt2d.size() > 0) {
373 int k =
rnd->Integer(
rt2d.size());
383 if (
rb != 1) { out->RebinX(
rb); }
395 int n = in->GetNbinsX();
405 double sg = 0, bg = 0,
er = 0;
407 TH1D* h = in->ProjectionY(
"timeBin",
bin,
bin);
409 if (h->GetEntries() > 0) {
411 TF1 f(
"f",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
413 f.SetParameter(0, h->GetMaximum());
414 f.SetParameter(1, h->GetMean());
415 f.SetParameter(2, h->GetRMS() * 0.25);
416 f.SetParameter(3, h->GetMinimum());
418 h->Fit(&f,
"Q",
"same");
420 bg = f.GetParameter(3) * h->GetNbinsX();
421 sg = h->GetSumOfWeights() - bg;
422 er = f.GetParError(3) * h->GetNbinsX();
449 int k =
rnd->Integer(
rt.size());
461 out.push_back(fit[0]);
471 out.push_back(fit[1]);
472 out.push_back(fit[2]);
Template definition of a multi-dimensional oscillation probability interpolation table.
Class to emulate L0 background for an arbitrarily sized detector.
bg_type generate_fitted(int rb=1)
Generate fitted L1 sample.
vector< double > build_NC(const int k, const int start)
Build NC sequence.
~JLightCurveBackgroundGenerator()
Destructor.
void configureRatio(const int inputNumberOfLines, const int outputNumberOfLines)
Configure generation ratio.
bg_type generate_poisson(const int domRate_Hz=500)
Generate pure poissionian background.
vector< vector< double > > rt
static vector< double > rebin(const vector< double > &in, const int rb)
Rebin vector.
bg_type generate_shuffled(bool randomizeRun=false)
Generate sample of L0 background The sampling of the L0 data is not sequential but random within the ...
void configureTimeWindow(const int T_ms)
Configure the duration of an output sample.
void setSeed(const UInt_t uSeed=0)
Set TRandom seed.
h2d_t * generate_H2D(int rb=1)
Generate 2D sample.
bg_type generate()
Generate sample of L0 background L0 data are randomly sampled from a single L0 dataset.
h2d_t * build_H2D(const int k, const int start)
Generate 2D histogram.
JLightCurveBackgroundGenerator(TFile *in, bool twoDim=false)
Default constructor.
static bg_type fit_H2D(h2d_t *in)
Fit 2D sample.
vector< vector< double > > nc
vector< double > loadHistogram(TH1D *in)
Load histogram values to vector, each bin is converted to an element.
vector< vector< double > > bg_type