simb::EvtTimeFNALBeam Class Reference

configurable FNAL Beam time distribution More...

#include <EvtTimeFNALBeam.h>

Inheritance diagram for simb::EvtTimeFNALBeam:
simb::EvtTimeDistI

List of all members.

Public Member Functions

 EvtTimeFNALBeam (const std::string &config)
virtual ~EvtTimeFNALBeam ()
virtual void Config (const std::string &config)
virtual double TimeOffset ()
virtual double TimeOffset (std::vector< double > bi)
virtual void PrintConfig (bool verbose=true)
 provide a means of printing the configuration
void SetGlobalOffset (double val)
 specific methods for this variant
double GetGlobalOffset () const
void SetTimeBetweenBuckets (double val)
double GetTimeBetweenBuckets () const
void SetBucketTimeSigma (double val)
double GetBucketTimeSigma () const
void SetNBucketsPerBatch (int ival)
int GetNBucketsPerBatch () const
void SetNFilledBucketsPerBatch (int ival)
int GetNFilledBucketsPerBatch () const
void SetBatchIntensities (std::vector< double > bi)
void SetDisallowedBatchMask (std::vector< int > disallow)

Private Member Functions

void CalculateCPDF (std::vector< double > batchi)

Private Attributes

double fGlobalOffset
 always displaced by this (in ns)
double fTimeBetweenBuckets
 time between buckets
double fBucketTimeSigma
 how wide is distribution in bucket
int fNBucketsPerBatch
int fNFilledBucketsPerBatch
std::vector< double > fCummulativeBatchPDF
 summed prob for batches
std::vector< int > fDisallowedBatchMask
 disallow individual batches

Detailed Description

configurable FNAL Beam time distribution

Author:
Robert Hatcher <rhatcher fnal.gov> Fermi National Accelerator Laboratory

2015-06-22

Version:
Id
EvtTimeFNALBeam.h,v 1.1 2015/06/30 18:01:24 rhatcher Exp

Definition at line 22 of file EvtTimeFNALBeam.h.


Constructor & Destructor Documentation

simb::EvtTimeFNALBeam::EvtTimeFNALBeam ( const std::string &  config  ) 

Definition at line 20 of file EvtTimeFNALBeam.cxx.

References Config(), and SetBatchIntensities().

00021     : EvtTimeDistI(config)
00022     , fGlobalOffset(0)
00023     , fTimeBetweenBuckets(1e9/53.103e6)
00024     , fBucketTimeSigma(0.750)
00025     , fNBucketsPerBatch(84)        // NOvA-era 81+3, MINOS-era 81+5
00026     , fNFilledBucketsPerBatch(81)  // 81 for both eras
00027     , fDisallowedBatchMask(6,0)    // don't disallow any
00028   { 
00029     std::vector<double> bi(6,1.0); // 6 equal batches
00030     SetBatchIntensities(bi);
00031     Config(config); 
00032   }

simb::EvtTimeFNALBeam::~EvtTimeFNALBeam (  )  [virtual]

Definition at line 34 of file EvtTimeFNALBeam.cxx.

00034 { ; }


Member Function Documentation

void simb::EvtTimeFNALBeam::CalculateCPDF ( std::vector< double >  batchi  )  [private]

Definition at line 108 of file EvtTimeFNALBeam.cxx.

References fCummulativeBatchPDF, and fDisallowedBatchMask.

Referenced by SetBatchIntensities(), and TimeOffset().

00109   {
00110     fCummulativeBatchPDF.clear();
00111     double sum = 0;
00112     size_t nbi = bi.size();
00113     for (size_t i=0; i < nbi; ++i) {
00114       sum += bi[i];
00115       fCummulativeBatchPDF.push_back(sum);
00116     }
00117     // normalize to unit probability
00118     for (size_t i=0; i < nbi; ++i) fCummulativeBatchPDF[i] /= sum;
00119     // make sure the mask vector keeps up (but never make it smaller)
00120     // allowing all new batches
00121     if ( nbi > fDisallowedBatchMask.size() ) 
00122       fDisallowedBatchMask.resize(nbi,0);
00123 
00124     /*
00125     for (size_t j=0; j<nbi; ++j) {
00126       std::cout << " CPDF[" << j << "] " << fCummulativeBatchPDF[j]
00127                 << "  " << ((fDisallowedBatchMask[j])?"dis":"") << "allowed"
00128                 << std::endl;
00129     }
00130     */
00131 
00132   }

void simb::EvtTimeFNALBeam::Config ( const std::string &  config  )  [virtual]

each schema must take a string that configures it it is up to the individual model to parse said string and extract parameters

Implements simb::EvtTimeDistI.

Definition at line 36 of file EvtTimeFNALBeam.cxx.

References PrintConfig().

Referenced by EvtTimeFNALBeam().

00037   {
00038     // parse config string
00039     std::cerr << "!!!!! EvtTimeFNALBeam - not yet up to parsing Config string "
00040               << ", ignoring:"
00041               << std::endl
00042               << "\"" << config << "\""
00043               << std::endl
00044               << "Starting with: "
00045               << std::endl;
00046     PrintConfig();
00047   }

double simb::EvtTimeFNALBeam::GetBucketTimeSigma (  )  const [inline]

Definition at line 53 of file EvtTimeFNALBeam.h.

References fBucketTimeSigma.

00053 { return fBucketTimeSigma; }

double simb::EvtTimeFNALBeam::GetGlobalOffset (  )  const [inline]

Definition at line 49 of file EvtTimeFNALBeam.h.

References fGlobalOffset.

00049 { return fGlobalOffset; }

int simb::EvtTimeFNALBeam::GetNBucketsPerBatch (  )  const [inline]

Definition at line 55 of file EvtTimeFNALBeam.h.

References fNBucketsPerBatch.

00055 { return fNBucketsPerBatch; }

int simb::EvtTimeFNALBeam::GetNFilledBucketsPerBatch (  )  const [inline]

Definition at line 57 of file EvtTimeFNALBeam.h.

References fNFilledBucketsPerBatch.

00057 { return fNFilledBucketsPerBatch; }

double simb::EvtTimeFNALBeam::GetTimeBetweenBuckets (  )  const [inline]

Definition at line 51 of file EvtTimeFNALBeam.h.

References fTimeBetweenBuckets.

00051 { return fTimeBetweenBuckets; }

void simb::EvtTimeFNALBeam::PrintConfig ( bool  verbose = true  )  [virtual]

provide a means of printing the configuration

Implements simb::EvtTimeDistI.

Definition at line 85 of file EvtTimeFNALBeam.cxx.

References fGlobalOffset.

Referenced by Config().

00086   {
00087     std::cout << "EvtTimeFNALBeam config: "
00088               << "  GlobalOffset " << fGlobalOffset << " ns"
00089               << std::endl;
00090   }

void simb::EvtTimeFNALBeam::SetBatchIntensities ( std::vector< double >  bi  ) 

Definition at line 93 of file EvtTimeFNALBeam.cxx.

References CalculateCPDF().

Referenced by EvtTimeFNALBeam().

00094   {
00095     CalculateCPDF(bi);
00096   }

void simb::EvtTimeFNALBeam::SetBucketTimeSigma ( double  val  )  [inline]

Definition at line 52 of file EvtTimeFNALBeam.h.

References fBucketTimeSigma.

00052 { fBucketTimeSigma=val; }

void simb::EvtTimeFNALBeam::SetDisallowedBatchMask ( std::vector< int >  disallow  ) 

Definition at line 98 of file EvtTimeFNALBeam.cxx.

References fCummulativeBatchPDF, and fDisallowedBatchMask.

00099   {
00100     size_t ndis = disallow.size();
00101     size_t nbi  = fCummulativeBatchPDF.size();
00102     fDisallowedBatchMask = disallow;
00103     // expand it so it's mirrors # of batch intensities
00104     // but allow all that haven't been set
00105     if ( nbi > ndis ) fDisallowedBatchMask.resize(nbi,0);
00106   }

void simb::EvtTimeFNALBeam::SetGlobalOffset ( double  val  )  [inline]

specific methods for this variant

Definition at line 48 of file EvtTimeFNALBeam.h.

References fGlobalOffset.

00048 { fGlobalOffset=val; }

void simb::EvtTimeFNALBeam::SetNBucketsPerBatch ( int  ival  )  [inline]

Definition at line 54 of file EvtTimeFNALBeam.h.

References fNBucketsPerBatch.

00054 { fNBucketsPerBatch=ival; }

void simb::EvtTimeFNALBeam::SetNFilledBucketsPerBatch ( int  ival  )  [inline]

Definition at line 56 of file EvtTimeFNALBeam.h.

References fNFilledBucketsPerBatch.

00056 { fNFilledBucketsPerBatch=ival; }

void simb::EvtTimeFNALBeam::SetTimeBetweenBuckets ( double  val  )  [inline]

Definition at line 50 of file EvtTimeFNALBeam.h.

References fTimeBetweenBuckets.

00050 { fTimeBetweenBuckets=val; }

double simb::EvtTimeFNALBeam::TimeOffset ( std::vector< double >  bi  )  [virtual]

Implements simb::EvtTimeDistI.

Definition at line 79 of file EvtTimeFNALBeam.cxx.

References CalculateCPDF(), and TimeOffset().

00080   {
00081     CalculateCPDF(bi);
00082     return TimeOffset();
00083   }

double simb::EvtTimeFNALBeam::TimeOffset (  )  [virtual]

return time within a 'record' in nanoseconds version taking array might be used for relative batch fractions that vary on a record-by-record basis

Implements simb::EvtTimeDistI.

Definition at line 49 of file EvtTimeFNALBeam.cxx.

References fBucketTimeSigma, fCummulativeBatchPDF, fDisallowedBatchMask, fGlobalOffset, fNBucketsPerBatch, fNFilledBucketsPerBatch, simb::EvtTimeDistI::fRndmGen, and fTimeBetweenBuckets.

Referenced by TimeOffset().

00050   {
00051     // calculate in small to large
00052 
00053     // pick a time within a bucket
00054     double offset = fRndmGen->Gaus(0.0,fBucketTimeSigma);
00055 
00056     // pick a bucket within a batch
00057     // assume all ~ buckets constant in batch until we have another model
00058     offset +=  fTimeBetweenBuckets * 
00059                (double)fRndmGen->Integer(fNFilledBucketsPerBatch);
00060 
00061     // pick a bucket
00062     bool   disallowed = true;
00063     size_t ibatch = 0;
00064     size_t nbatch = fCummulativeBatchPDF.size();
00065     double r = 2;
00066     while ( disallowed ) {
00067       r = fRndmGen->Uniform();
00068       for (ibatch=0; ibatch<nbatch; ++ibatch) {
00069         if ( r <= fCummulativeBatchPDF[ibatch] ) break;
00070       }
00071       disallowed = ( fDisallowedBatchMask[ibatch] != 0 );
00072     }
00073     offset += fTimeBetweenBuckets*(double)fNBucketsPerBatch*(double)ibatch;
00074 
00075     // finally the global offset
00076     return offset + fGlobalOffset;
00077   }


Member Data Documentation

how wide is distribution in bucket

Definition at line 68 of file EvtTimeFNALBeam.h.

Referenced by GetBucketTimeSigma(), SetBucketTimeSigma(), and TimeOffset().

std::vector<double> simb::EvtTimeFNALBeam::fCummulativeBatchPDF [private]

summed prob for batches

Definition at line 71 of file EvtTimeFNALBeam.h.

Referenced by CalculateCPDF(), SetDisallowedBatchMask(), and TimeOffset().

std::vector<int> simb::EvtTimeFNALBeam::fDisallowedBatchMask [private]

disallow individual batches

Definition at line 72 of file EvtTimeFNALBeam.h.

Referenced by CalculateCPDF(), SetDisallowedBatchMask(), and TimeOffset().

always displaced by this (in ns)

Definition at line 66 of file EvtTimeFNALBeam.h.

Referenced by GetGlobalOffset(), PrintConfig(), SetGlobalOffset(), and TimeOffset().

Definition at line 69 of file EvtTimeFNALBeam.h.

Referenced by GetNBucketsPerBatch(), SetNBucketsPerBatch(), and TimeOffset().

time between buckets

Definition at line 67 of file EvtTimeFNALBeam.h.

Referenced by GetTimeBetweenBuckets(), SetTimeBetweenBuckets(), and TimeOffset().


The documentation for this class was generated from the following files:

Generated on 3 Dec 2018 for loon by  doxygen 1.6.1