Class to emulate L0 background for an arbitrarily sized detector.  
 More...
#include <JL0BackgroundSimulator.hh>
Class to emulate L0 background for an arbitrarily sized detector. 
Definition at line 57 of file JL0BackgroundSimulator.hh.
 
◆ JL0BackgroundSimulator()
  
  
      
        
          | JSUPERNOVA::JL0BackgroundSimulator::JL0BackgroundSimulator  | 
          ( | 
          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  | 
  
   
Definition at line 83 of file JL0BackgroundSimulator.hh.
   90       TString rt_tag = 
".RT_DET_SUM";
 
   91       TString nc_tag = 
".NC_DET_SUM";
 
   92       TString rt2d_tag = 
".RT2D_DET";
 
   96       TIter iter(in->GetListOfKeys());
 
   98       for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  100         const TString tag(key->GetName());
 
  103         if (tag.EndsWith(rt_tag)) {
 
  105           TString rt_hist_tag = tag;
 
  106           TString run_tag = TString(tag, tag.Length() - rt_tag.Length());
 
  108           TString nc_hist_tag = run_tag + nc_tag;
 
  110           TH1D* RT = (TH1D*) in->Get(rt_hist_tag);
 
  111           TH1D* NC = (TH1D*) in->Get(nc_hist_tag);
 
  116           int n = nc_buf.size();
 
  123           for (
int i = 0; i < 
n; i++) {
 
  126               nc.back().push_back( nc_buf[i] );
 
  127               for (
int j = 100 * i; 
j < 100 * (i + 1); 
j++) {
 
  128                 rt.back().push_back( rt_buf[
j] );
 
  134             TString rt2d_hist_tag = run_tag + rt2d_tag;
 
  135             h2d_t* RT2D = (
h2d_t*) in->Get(rt2d_hist_tag);
 
  138               RT2D->SetDirectory(0);
 
  139               rt2d.push_back(RT2D);
 
 
 
 
◆ ~JL0BackgroundSimulator()
  
  
      
        
          | JSUPERNOVA::JL0BackgroundSimulator::~JL0BackgroundSimulator  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
 
◆ configureTimeWindow()
  
  
      
        
          | void JSUPERNOVA::JL0BackgroundSimulator::configureTimeWindow  | 
          ( | 
          const int  | 
          T_ms | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
 
◆ setSeed()
  
  
      
        
          | void JSUPERNOVA::JL0BackgroundSimulator::setSeed  | 
          ( | 
          const UInt_t  | 
          uSeed = 0 | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
 
◆ configureRatio()
  
  
      
        
          | void JSUPERNOVA::JL0BackgroundSimulator::configureRatio  | 
          ( | 
          const int  | 
          iSize,  | 
         
        
           | 
           | 
          const int  | 
          oSize  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
Set rebinning ratio. 
- Parameters
 - 
  
    | rebin | void setRebin(const int rb) { rebin = rb; } Configure generation ratio | 
    | iSize | number of lines of input detector  | 
    | oSize | number of lines of output detector  | 
  
   
Definition at line 189 of file JL0BackgroundSimulator.hh.
 
 
◆ generate()
  
  
      
        
          | bg_type JSUPERNOVA::JL0BackgroundSimulator::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 204 of file JL0BackgroundSimulator.hh.
  208       int k = 
rnd->Integer(
rt.size());
 
  212       int start = 
rnd->Integer(limit);
 
  214       for (
int i = 0; i < 
genRatio; i++) {
 
 
 
 
◆ generate_poisson()
  
  
      
        
          | bg_type JSUPERNOVA::JL0BackgroundSimulator::generate_poisson  | 
          ( | 
          const int  | 
          domRate_Hz = 500 | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Generate pure poissionian background. 
Definition at line 233 of file JL0BackgroundSimulator.hh.
  237       double mu = 
outputSize * 18 * domRate_Hz * 1.0e-3; 
 
  239       for (
unsigned i = 0; i < out[0].size(); i++) {
 
  241         double count  = 
rnd->Poisson(mu);
 
 
 
 
◆ generate_shuffled()
  
  
      
        
          | bg_type JSUPERNOVA::JL0BackgroundSimulator::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 258 of file JL0BackgroundSimulator.hh.
  262       int nRuns = 
rt.size();
 
  264       int k = 
rnd->Integer(nRuns);
 
  269       int offset = 
rnd->Integer(100);
 
  271       for (
int i = 0; i < 
genRatio; i++) {
 
  273         int start = 100 * 
rnd->Integer(
nc[k].size() - ceil(
TWindow_ms / 100.0)) + offset;
 
  285           k = 
rnd->Integer(nRuns);
 
 
 
 
◆ build_H2D()
  
  
      
        
          | h2d_t* JSUPERNOVA::JL0BackgroundSimulator::build_H2D  | 
          ( | 
          const int  | 
          k,  | 
         
        
           | 
           | 
          const int  | 
          start  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
Generate 2D histogram. 
Definition at line 297 of file JL0BackgroundSimulator.hh.
  301       int ny   = proto->GetNbinsY();
 
  302       int ymin = proto->GetYaxis()->GetXmin(); 
 
  303       int ymax = proto->GetYaxis()->GetXmax();
 
  307       for (
int i = 0; i < 
genRatio; i++) {
 
  313           for (
int ybin = 1; ybin <= 
rt2d[k]->GetNbinsY(); ybin++) {
 
  315             double val = 
rt2d[k]->GetBinContent(xbin, ybin);    
 
  317             double bcx = ((TAxis*)out->GetXaxis())->GetBinCenter(
j + 1);
 
  318             double bcy = ((TAxis*)out->GetYaxis())->GetBinCenter(ybin);
 
  320             out->Fill(bcx, bcy, val);
 
 
 
 
◆ build_NC()
  
  
      
        
          | vector<double> JSUPERNOVA::JL0BackgroundSimulator::build_NC  | 
          ( | 
          const int  | 
          k,  | 
         
        
           | 
           | 
          const int  | 
          start  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
 
◆ rebin()
  
  
      
        
          | static vector<double> JSUPERNOVA::JL0BackgroundSimulator::rebin  | 
          ( | 
          const vector< double > &  | 
          in,  | 
         
        
           | 
           | 
          const int  | 
          rb  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inlinestatic   | 
  
 
 
◆ generate_H2D()
  
  
      
        
          | h2d_t* JSUPERNOVA::JL0BackgroundSimulator::generate_H2D  | 
          ( | 
          int  | 
          rb = 1 | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Generate 2D sample. 
Definition at line 375 of file JL0BackgroundSimulator.hh.
  379       if (
rt2d.size() > 0) {
 
  381         int k = 
rnd->Integer(
rt2d.size());
 
  385         int start = 
rnd->Integer(limit);
 
  391       if (rb != 1) { out->RebinX(rb); }
 
 
 
 
◆ fit_H2D()
  
  
      
        
          | static bg_type JSUPERNOVA::JL0BackgroundSimulator::fit_H2D  | 
          ( | 
          h2d_t *  | 
          in | ) | 
           | 
         
       
   | 
  
inlinestatic   | 
  
 
Fit 2D sample. 
Definition at line 401 of file JL0BackgroundSimulator.hh.
  403       int n = in->GetNbinsX();
 
  411       for (
int bin = 1; bin <= 
n; bin++) {
 
  413         double sg = 0, bg = 0, er = 0;
 
  415         TH1D* h = in->ProjectionY(
"timeBin", bin, bin);
 
  417         if (h->GetEntries() > 0) {
 
  419           TF1 f(
"f", 
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
 
  421           f.SetParameter(0, h->GetMaximum());
 
  422           f.SetParameter(1, h->GetMean());
 
  423           f.SetParameter(2, h->GetRMS() * 0.25);
 
  424           f.SetParameter(3, h->GetMinimum());
 
  426           h->Fit(&f, 
"Q", 
"same");
 
  428           bg = f.GetParameter(3) * h->GetNbinsX();
 
  429           sg = h->GetSumOfWeights() - bg;
 
  430           er = f.GetParError(3) * h->GetNbinsX();
 
 
 
 
◆ generate_fitted()
  
  
      
        
          | bg_type JSUPERNOVA::JL0BackgroundSimulator::generate_fitted  | 
          ( | 
          int  | 
          rb = 1 | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Generate fitted L1 sample. 
Definition at line 453 of file JL0BackgroundSimulator.hh.
  457       int k = 
rnd->Integer(
rt.size());
 
  461       int start = 
rnd->Integer(limit);
 
  465       if (rb != 1) { sample->RebinX(rb); }
 
  469       out.push_back(fit[0]);
 
  479       out.push_back(fit[1]);
 
  480       out.push_back(fit[2]);
 
 
 
 
◆ rt
  
  
      
        
          | vector<vector<double> > JSUPERNOVA::JL0BackgroundSimulator::rt | 
         
       
   | 
  
private   | 
  
 
 
◆ nc
  
  
      
        
          | vector<vector<double> > JSUPERNOVA::JL0BackgroundSimulator::nc | 
         
       
   | 
  
private   | 
  
 
 
◆ rt2d
  
  
      
        
          | vector<h2d_t*> JSUPERNOVA::JL0BackgroundSimulator::rt2d | 
         
       
   | 
  
private   | 
  
 
 
◆ TWindow_ms
  
  
      
        
          | int JSUPERNOVA::JL0BackgroundSimulator::TWindow_ms | 
         
       
   | 
  
private   | 
  
 
 
◆ genRatio
  
  
      
        
          | int JSUPERNOVA::JL0BackgroundSimulator::genRatio | 
         
       
   | 
  
private   | 
  
 
 
◆ outputSize
  
  
      
        
          | int JSUPERNOVA::JL0BackgroundSimulator::outputSize | 
         
       
   | 
  
private   | 
  
 
 
◆ genScale
  
  
      
        
          | double JSUPERNOVA::JL0BackgroundSimulator::genScale | 
         
       
   | 
  
private   | 
  
 
 
◆ rnd
  
  
      
        
          | TRandom* JSUPERNOVA::JL0BackgroundSimulator::rnd | 
         
       
   | 
  
private   | 
  
 
 
The documentation for this class was generated from the following file: