MQwMockable.h

Go to the documentation of this file.
00001 /**********************************************************\
00002 * File: MQwMockable.h                                      *
00003 *                                                          *
00004 * Author: P. King                                          *
00005 * Date:   Tue Mar 29 13:08:12 EDT 2011                     *
00006 \**********************************************************/
00007 
00008 #ifndef __MQWMOCKABLE__
00009 #define __MQWMOCKABLE__
00010 
00011 // Boost math library for random number generation
00012 #include "boost/random.hpp"
00013 
00014 //jpan: Mersenne Twistor: A 623-diminsionally equidistributed
00015 //uniform pseudorandom number generator
00016 #include "TRandom3.h"
00017 
00018 
00019 class MQwMockable {
00020 /****************************************************************//**
00021  *  Class: MQwMockable
00022  *         Mix-in class to enable mock-data generation for a
00023  *         data element.
00024  *         Only the data element classes which actually contain
00025  *         raw data (such as QwVQWK_Channel, QwScaler_Channel, etc.)
00026  *         should inherit from this class.
00027  ******************************************************************/
00028 public:
00029   MQwMockable(): fUseExternalRandomVariable(false),
00030      fMockAsymmetry(0.0), fMockGaussianMean(0.0),
00031                  fMockGaussianSigma(0.0)
00032   {
00033     // Mock drifts
00034     fMockDriftAmplitude.clear();
00035     fMockDriftFrequency.clear();
00036     fMockDriftPhase.clear();
00037   }
00038   virtual ~MQwMockable() {
00039     fMockDriftAmplitude.clear();
00040     fMockDriftFrequency.clear();
00041     fMockDriftPhase.clear();
00042   }
00043 
00044 
00045   /// \name Parity mock data generation
00046   // @{
00047   /// Set a single set of harmonic drift parameters
00048   void  SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency);
00049   /// Add drift parameters to the internal set
00050   void  AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency);
00051   /// Set the normal random event parameters
00052   void  SetRandomEventParameters(Double_t mean, Double_t sigma);
00053   /// Set the helicity asymmetry
00054   void  SetRandomEventAsymmetry(Double_t asymmetry);
00055 
00056   /// Return a random value generated either from the internal or
00057   /// external Random Variable.
00058   Double_t GetRandomValue();
00059 
00060   /// Internally generate random event data
00061   virtual void  RandomizeEventData(int helicity = 0, double time = 0.0) = 0;
00062 
00063   /// Encode the event data into a CODA buffer  
00064   virtual void EncodeEventData(std::vector<UInt_t> &buffer) = 0;
00065 
00066   /// Set the flag to use an externally provided random variable
00067   void  UseExternalRandomVariable() { fUseExternalRandomVariable = true; };
00068   /// Set the externally provided random variable
00069   void  SetExternalRandomVariable(Double_t random_variable) {
00070     fUseExternalRandomVariable = true;
00071     fExternalRandomVariable = random_variable;
00072   };
00073   // @}
00074 
00075  protected:
00076   /// \name Parity mock data generation
00077   // @{
00078   /// Internal randomness generator
00079   static boost::mt19937 fRandomnessGenerator;
00080   /// Internal normal probability distribution
00081   static boost::normal_distribution<double> fNormalDistribution;
00082   /// Internal normal random variable
00083   static boost::variate_generator
00084     < boost::mt19937, boost::normal_distribution<double> > fNormalRandomVariable;
00085   /// Flag to use an externally provided normal random variable
00086   bool fUseExternalRandomVariable;
00087   /// Externally provided normal random variable
00088   double  fExternalRandomVariable;
00089 
00090   // Parameters of the mock data
00091   Double_t fMockAsymmetry;     ///< Helicity asymmetry
00092   Double_t fMockGaussianMean;  ///< Mean of normal distribution
00093   Double_t fMockGaussianSigma; ///< Sigma of normal distribution
00094   std::vector<Double_t> fMockDriftAmplitude; ///< Harmonic drift amplitude
00095   std::vector<Double_t> fMockDriftFrequency; ///< Harmonic drift frequency
00096   std::vector<Double_t> fMockDriftPhase;     ///< Harmonic drift phase
00097   // @}
00098 };
00099 
00100 #endif

Generated on 19 Feb 2017 for QwAnalysis by  doxygen 1.6.1