MQwMockable.cc

Go to the documentation of this file.
00001 #include "MQwMockable.h"
00002 
00003 // Randomness generator: Mersenne twister with period 2^19937 - 1
00004 //
00005 // This is defined as static to avoid getting stuck with 100% correlated
00006 // ADC channels when each channel goes through the same list of pseudo-
00007 // random numbers...
00008 boost::mt19937 MQwMockable::fRandomnessGenerator;
00009 boost::normal_distribution<double> MQwMockable::fNormalDistribution;
00010 // The boost::variate_generator has operator() overloaded to get a new random
00011 // value according to the distribution in the second template argument, based
00012 // on the uniform random value generated by the first template argument.
00013 // For example: fNormalRandomVariable() will return a random normal variable.
00014 boost::variate_generator < boost::mt19937, boost::normal_distribution<double> >
00015   MQwMockable::fNormalRandomVariable(fRandomnessGenerator, fNormalDistribution);
00016 
00017 
00018 
00019 void MQwMockable::SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
00020 {
00021   // Clear existing values
00022   fMockDriftAmplitude.clear();
00023   fMockDriftFrequency.clear();
00024   fMockDriftPhase.clear();
00025   // Add new values
00026   fMockDriftAmplitude.push_back(amplitude);
00027   fMockDriftFrequency.push_back(frequency);
00028   fMockDriftPhase.push_back(phase);
00029   return;
00030 }
00031 
00032 void MQwMockable::AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
00033 {
00034   // Add new values
00035   fMockDriftAmplitude.push_back(amplitude);
00036   fMockDriftFrequency.push_back(frequency);
00037   fMockDriftPhase.push_back(phase);
00038   return;
00039 }
00040 
00041 void MQwMockable::SetRandomEventParameters(Double_t mean, Double_t sigma)
00042 {
00043   fMockGaussianMean = mean;
00044   fMockGaussianSigma = sigma;
00045   return;
00046 }
00047 
00048 void MQwMockable::SetRandomEventAsymmetry(Double_t asymmetry)
00049 {
00050   fMockAsymmetry = asymmetry;
00051   return;
00052 }
00053 
00054 Double_t MQwMockable::GetRandomValue(){
00055   Double_t random_variable;
00056   if (fUseExternalRandomVariable)
00057     // external normal random variable
00058     random_variable = fExternalRandomVariable;
00059   else
00060     // internal normal random variable
00061     random_variable = fNormalRandomVariable();
00062   return random_variable;
00063 }
00064 

Generated on 19 Feb 2017 for QwAnalysis by  doxygen 1.6.1