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 57 of file JLightCurveBackgroundGenerator.hh.
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 83 of file JLightCurveBackgroundGenerator.hh.
89 TString rt_tag =
".RT_DET_SUM";
90 TString nc_tag =
".NC_DET_SUM";
91 TString rt2d_tag =
".RT2D_DET";
95 TIter iter(
in->GetListOfKeys());
97 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
99 const TString tag(key->GetName());
102 if (tag.EndsWith(rt_tag)) {
104 TString rt_hist_tag = tag;
105 TString run_tag = TString(tag, tag.Length() - rt_tag.Length());
107 TString nc_hist_tag = run_tag + nc_tag;
109 TH1D* RT = (TH1D*)
in->Get(rt_hist_tag);
110 TH1D* NC = (TH1D*)
in->Get(nc_hist_tag);
115 int n = nc_buf.size();
122 for (
int i = 0; i <
n; i++) {
125 nc.back().push_back( nc_buf[i] );
126 for (
int j = 100 * i;
j < 100 * (i + 1);
j++) {
127 rt.back().push_back( rt_buf[
j] );
133 TString rt2d_hist_tag = run_tag + rt2d_tag;
137 RT2D->SetDirectory(0);
138 rt2d.push_back(RT2D);
vector< vector< double > > rt
vector< vector< double > > nc
alias put_queue eval echo n
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
vector< double > loadHistogram(TH1D *in)
Load histogram values to vector, each bin is converted to an element.
JSUPERNOVA::JLightCurveBackgroundGenerator::~JLightCurveBackgroundGenerator |
( |
| ) |
|
|
inline |
void JSUPERNOVA::JLightCurveBackgroundGenerator::configureTimeWindow |
( |
const int |
T_ms | ) |
|
|
inline |
void JSUPERNOVA::JLightCurveBackgroundGenerator::setSeed |
( |
const UInt_t |
uSeed = 0 | ) |
|
|
inline |
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 179 of file JLightCurveBackgroundGenerator.hh.
182 genRatio = outputNumberOfLines / inputNumberOfLines;
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 194 of file JLightCurveBackgroundGenerator.hh.
198 int k =
rnd->Integer(
rt.size());
202 int start =
rnd->Integer(limit);
204 for (
int i = 0; i <
genRatio; i++) {
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
vector< vector< double > > bg_type
vector< vector< double > > rt
vector< vector< double > > nc
bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::generate_poisson |
( |
const int |
domRate_Hz = 500 | ) |
|
|
inline |
Generate pure poissionian background.
Definition at line 223 of file JLightCurveBackgroundGenerator.hh.
227 double mu =
outputSize * 18 * domRate_Hz * 1.0e-3;
229 for (
unsigned i = 0; i < out[0].size(); i++) {
vector< vector< double > > bg_type
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 248 of file JLightCurveBackgroundGenerator.hh.
252 int nRuns =
rt.size();
254 int k =
rnd->Integer(nRuns);
259 int offset =
rnd->Integer(100);
261 for (
int i = 0; i <
genRatio; i++) {
263 int start = 100 *
rnd->Integer(
nc[k].size() - ceil(
TWindow_ms / 100.0)) + offset;
275 k =
rnd->Integer(nRuns);
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
vector< vector< double > > bg_type
vector< vector< double > > rt
vector< vector< double > > nc
h2d_t* JSUPERNOVA::JLightCurveBackgroundGenerator::build_H2D |
( |
const int |
k, |
|
|
const int |
start |
|
) |
| |
|
inline |
Generate 2D histogram.
Definition at line 287 of file JLightCurveBackgroundGenerator.hh.
291 int ny = proto->GetNbinsY();
292 int ymin = proto->GetYaxis()->GetXmin();
293 int ymax = proto->GetYaxis()->GetXmax();
297 for (
int i = 0; i <
genRatio; i++) {
303 for (
int ybin = 1; ybin <=
rt2d[
k]->GetNbinsY(); ybin++) {
305 double val =
rt2d[
k]->GetBinContent(xbin, ybin);
307 double bcx = ((TAxis*)out->GetXaxis())->GetBinCenter(
j + 1);
308 double bcy = ((TAxis*)out->GetYaxis())->GetBinCenter(ybin);
310 out->Fill(bcx, bcy, val);
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
vector<double> JSUPERNOVA::JLightCurveBackgroundGenerator::build_NC |
( |
const int |
k, |
|
|
const int |
start |
|
) |
| |
|
inline |
static vector<double> JSUPERNOVA::JLightCurveBackgroundGenerator::rebin |
( |
const vector< double > & |
in, |
|
|
const int |
rb |
|
) |
| |
|
inlinestatic |
h2d_t* JSUPERNOVA::JLightCurveBackgroundGenerator::generate_H2D |
( |
int |
rb = 1 | ) |
|
|
inline |
Generate 2D sample.
Definition at line 365 of file JLightCurveBackgroundGenerator.hh.
369 if (
rt2d.size() > 0) {
375 int start =
rnd->Integer(limit);
381 if (rb != 1) { out->RebinX(rb); }
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
h2d_t * build_H2D(const int k, const int start)
Generate 2D histogram.
static bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::fit_H2D |
( |
h2d_t * |
in | ) |
|
|
inlinestatic |
Fit 2D sample.
Definition at line 391 of file JLightCurveBackgroundGenerator.hh.
393 int n =
in->GetNbinsX();
401 for (
int bin = 1; bin <=
n; bin++) {
403 double sg = 0, bg = 0, er = 0;
405 TH1D* h =
in->ProjectionY(
"timeBin", bin, bin);
407 if (h->GetEntries() > 0) {
409 TF1
f(
"f",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
411 f.SetParameter(0, h->GetMaximum());
412 f.SetParameter(1, h->GetMean());
413 f.SetParameter(2, h->GetRMS() * 0.25);
414 f.SetParameter(3, h->GetMinimum());
416 h->Fit(&
f,
"Q",
"same");
418 bg =
f.GetParameter(3) * h->GetNbinsX();
419 sg = h->GetSumOfWeights() - bg;
420 er =
f.GetParError(3) * h->GetNbinsX();
vector< vector< double > > bg_type
alias put_queue eval echo n
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
bg_type JSUPERNOVA::JLightCurveBackgroundGenerator::generate_fitted |
( |
int |
rb = 1 | ) |
|
|
inline |
Generate fitted L1 sample.
Definition at line 443 of file JLightCurveBackgroundGenerator.hh.
447 int k =
rnd->Integer(
rt.size());
451 int start =
rnd->Integer(limit);
455 if (rb != 1) { sample->RebinX(rb); }
459 out.push_back(fit[0]);
469 out.push_back(fit[1]);
470 out.push_back(fit[2]);
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
h2d_t * build_H2D(const int k, const int start)
Generate 2D histogram.
vector< vector< double > > bg_type
vector< vector< double > > rt
static vector< double > rebin(const vector< double > &in, const int rb)
Rebin vector.
vector< double > build_NC(const int k, const int start)
Build NC sequence.
static bg_type fit_H2D(h2d_t *in)
Fit 2D sample.
vector<vector<double> > JSUPERNOVA::JLightCurveBackgroundGenerator::rt |
|
private |
vector<vector<double> > JSUPERNOVA::JLightCurveBackgroundGenerator::nc |
|
private |
vector<h2d_t*> JSUPERNOVA::JLightCurveBackgroundGenerator::rt2d |
|
private |
int JSUPERNOVA::JLightCurveBackgroundGenerator::TWindow_ms |
|
private |
int JSUPERNOVA::JLightCurveBackgroundGenerator::genRatio |
|
private |
int JSUPERNOVA::JLightCurveBackgroundGenerator::outputSize |
|
private |
double JSUPERNOVA::JLightCurveBackgroundGenerator::genScale |
|
private |
TRandom* JSUPERNOVA::JLightCurveBackgroundGenerator::rnd |
|
private |
The documentation for this class was generated from the following file: