Class to emulate L0 background for an arbitrarily sized detector.
More...
#include <JLightCurveBackgroundGenerator.hh>
Class to emulate L0 background for an arbitrarily sized detector.
Definition at line 59 of file JLightCurveBackgroundGenerator.hh.
◆ JLightCurveBackgroundGenerator()
JSUPERNOVA::JLightCurveBackgroundGenerator::JLightCurveBackgroundGenerator |
( |
TFile * |
in, |
|
|
bool |
twoDim = false |
|
) |
| |
|
inline |
Default constructor.
The input file contains a sequence of histograms with sampled L0 data; Each histogram is loaded as a vector, which will be considered as an individual L0 dataset.
- Parameters
-
in | input file from JRipple |
twoDim | make 2D histogram with distribution of hit time differences vs time |
Definition at line 85 of file JLightCurveBackgroundGenerator.hh.
91 TString rt_tag =
".RT_DET_SUM";
92 TString nc_tag =
".NC_DET_SUM";
93 TString rt2d_tag =
".RT2D_DET";
97 TIter iter(in->GetListOfKeys());
99 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
101 const TString tag(key->GetName());
104 if (tag.EndsWith(rt_tag)) {
106 TString rt_hist_tag = tag;
107 TString run_tag = TString(tag, tag.Length() - rt_tag.Length());
109 TString nc_hist_tag = run_tag + nc_tag;
111 TH1D* RT = (TH1D*) in->Get(rt_hist_tag);
112 TH1D* NC = (TH1D*) in->Get(nc_hist_tag);
117 int n = nc_buf.size();
124 for (
int i = 0; i <
n; i++) {
127 nc.back().push_back( nc_buf[i] );
128 for (
int j = 100 * i;
j < 100 * (i + 1);
j++) {
129 rt.back().push_back( rt_buf[
j] );
135 TString rt2d_hist_tag = run_tag + rt2d_tag;
136 h2d_t* RT2D = (
h2d_t*) in->Get(rt2d_hist_tag);
139 RT2D->SetDirectory(0);
140 rt2d.push_back(RT2D);
vector< vector< double > > rt
vector< vector< double > > nc
vector< double > loadHistogram(TH1D *in)
Load histogram values to vector, each bin is converted to an element.
◆ ~JLightCurveBackgroundGenerator()
JSUPERNOVA::JLightCurveBackgroundGenerator::~JLightCurveBackgroundGenerator |
( |
| ) |
|
|
inline |
◆ configureTimeWindow()
void JSUPERNOVA::JLightCurveBackgroundGenerator::configureTimeWindow |
( |
const int |
T_ms | ) |
|
|
inline |
◆ setSeed()
void JSUPERNOVA::JLightCurveBackgroundGenerator::setSeed |
( |
const UInt_t |
uSeed = 0 | ) |
|
|
inline |
◆ configureRatio()
void JSUPERNOVA::JLightCurveBackgroundGenerator::configureRatio |
( |
const int |
inputNumberOfLines, |
|
|
const int |
outputNumberOfLines |
|
) |
| |
|
inline |
Configure generation ratio.
- Parameters
-
inputNumberOfLines | number of lines of input detector |
outputNumberOfLines | number of lines of output detector |
Definition at line 181 of file JLightCurveBackgroundGenerator.hh.
184 genRatio = outputNumberOfLines / inputNumberOfLines;
◆ generate()
bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::generate |
( |
| ) |
|
|
inline |
Generate sample of L0 background L0 data are randomly sampled from a single L0 dataset.
- Returns
- 2D vector with hit count and number of active channels as a function of time
Definition at line 196 of file JLightCurveBackgroundGenerator.hh.
200 int k =
rnd->Integer(
rt.size());
204 int start =
rnd->Integer(limit);
206 for (
int i = 0; i <
genRatio; i++) {
vector< vector< double > > bg_type
◆ generate_poisson()
bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::generate_poisson |
( |
const int |
domRate_Hz = 500 | ) |
|
|
inline |
Generate pure poissionian background.
Definition at line 225 of file JLightCurveBackgroundGenerator.hh.
229 double mu =
outputSize * 18 * domRate_Hz * 1.0e-3;
231 for (
unsigned i = 0; i < out[0].size(); i++) {
233 double count =
rnd->Poisson(mu);
◆ generate_shuffled()
bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::generate_shuffled |
( |
bool |
randomizeRun = false | ) |
|
|
inline |
Generate sample of L0 background The sampling of the L0 data is not sequential but random within the L0 dataset.
- Returns
- 2D vector with hit count and number of active channels as a function of time
Definition at line 250 of file JLightCurveBackgroundGenerator.hh.
254 int nRuns =
rt.size();
256 int k =
rnd->Integer(nRuns);
261 int offset =
rnd->Integer(100);
263 for (
int i = 0; i <
genRatio; i++) {
265 int start = 100 *
rnd->Integer(
nc[k].size() - ceil(
TWindow_ms / 100.0)) + offset;
277 k =
rnd->Integer(nRuns);
◆ build_H2D()
h2d_t* JSUPERNOVA::JLightCurveBackgroundGenerator::build_H2D |
( |
const int |
k, |
|
|
const int |
start |
|
) |
| |
|
inline |
Generate 2D histogram.
Definition at line 289 of file JLightCurveBackgroundGenerator.hh.
293 int ny = proto->GetNbinsY();
294 int ymin = proto->GetYaxis()->GetXmin();
295 int ymax = proto->GetYaxis()->GetXmax();
299 for (
int i = 0; i <
genRatio; i++) {
305 for (
int ybin = 1; ybin <=
rt2d[k]->GetNbinsY(); ybin++) {
307 double val =
rt2d[k]->GetBinContent(xbin, ybin);
309 double bcx = ((TAxis*)out->GetXaxis())->GetBinCenter(
j + 1);
310 double bcy = ((TAxis*)out->GetYaxis())->GetBinCenter(ybin);
312 out->Fill(bcx, bcy, val);
◆ build_NC()
vector<double> JSUPERNOVA::JLightCurveBackgroundGenerator::build_NC |
( |
const int |
k, |
|
|
const int |
start |
|
) |
| |
|
inline |
◆ rebin()
static vector<double> JSUPERNOVA::JLightCurveBackgroundGenerator::rebin |
( |
const vector< double > & |
in, |
|
|
const int |
rb |
|
) |
| |
|
inlinestatic |
◆ generate_H2D()
h2d_t* JSUPERNOVA::JLightCurveBackgroundGenerator::generate_H2D |
( |
int |
rb = 1 | ) |
|
|
inline |
Generate 2D sample.
Definition at line 367 of file JLightCurveBackgroundGenerator.hh.
371 if (
rt2d.size() > 0) {
373 int k =
rnd->Integer(
rt2d.size());
377 int start =
rnd->Integer(limit);
383 if (rb != 1) { out->RebinX(rb); }
h2d_t * build_H2D(const int k, const int start)
Generate 2D histogram.
◆ fit_H2D()
static bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::fit_H2D |
( |
h2d_t * |
in | ) |
|
|
inlinestatic |
Fit 2D sample.
Definition at line 393 of file JLightCurveBackgroundGenerator.hh.
395 int n = in->GetNbinsX();
403 for (
int bin = 1; bin <=
n; bin++) {
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();
◆ generate_fitted()
bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::generate_fitted |
( |
int |
rb = 1 | ) |
|
|
inline |
Generate fitted L1 sample.
Definition at line 445 of file JLightCurveBackgroundGenerator.hh.
449 int k =
rnd->Integer(
rt.size());
453 int start =
rnd->Integer(limit);
457 if (rb != 1) { sample->RebinX(rb); }
461 out.push_back(fit[0]);
471 out.push_back(fit[1]);
472 out.push_back(fit[2]);
vector< double > build_NC(const int k, const int start)
Build NC sequence.
static vector< double > rebin(const vector< double > &in, const int rb)
Rebin vector.
static bg_type fit_H2D(h2d_t *in)
Fit 2D sample.
◆ rt
vector<vector<double> > JSUPERNOVA::JLightCurveBackgroundGenerator::rt |
|
private |
◆ nc
vector<vector<double> > JSUPERNOVA::JLightCurveBackgroundGenerator::nc |
|
private |
◆ rt2d
vector<h2d_t*> JSUPERNOVA::JLightCurveBackgroundGenerator::rt2d |
|
private |
◆ TWindow_ms
int JSUPERNOVA::JLightCurveBackgroundGenerator::TWindow_ms |
|
private |
◆ genRatio
int JSUPERNOVA::JLightCurveBackgroundGenerator::genRatio |
|
private |
◆ outputSize
int JSUPERNOVA::JLightCurveBackgroundGenerator::outputSize |
|
private |
◆ genScale
double JSUPERNOVA::JLightCurveBackgroundGenerator::genScale |
|
private |
◆ rnd
TRandom* JSUPERNOVA::JLightCurveBackgroundGenerator::rnd |
|
private |
The documentation for this class was generated from the following file: