JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
MQwMockable.h
Go to the documentation of this file.
1/**********************************************************\
2* File: MQwMockable.h *
3* *
4* Author: P. King *
5* Date: Tue Mar 29 13:08:12 EDT 2011 *
6\**********************************************************/
7
8#pragma once
9
10// Boost math library for random number generation
11#include "boost/random.hpp"
12
13//jpan: Mersenne Twistor: A 623-diminsionally equidistributed
14//uniform pseudorandom number generator
15#include "TRandom3.h"
16
17class QwParameterFile;
18
19/**
20 * \class MQwMockable
21 * \ingroup QwAnalysis
22 * \brief Mix-in class enabling mock data generation for hardware channels
23 *
24 * Provides infrastructure for generating simulated data with configurable
25 * asymmetries, noise characteristics, and harmonic drifts. Supports both
26 * internal random number generation and external random variables.
27 * Used by hardware channel classes to enable Monte Carlo studies and
28 * testing without real data acquisition hardware.
29 */
31/****************************************************************//**
32 * Class: MQwMockable
33 * Mix-in class to enable mock-data generation for a
34 * data element.
35 * Only the data element classes which actually contain
36 * raw data (such as QwVQWK_Channel, QwScaler_Channel, etc.)
37 * should inherit from this class.
38 ******************************************************************/
39public:
44 {
45 // Mock drifts
46 fMockDriftAmplitude.clear();
47 fMockDriftFrequency.clear();
48 fMockDriftPhase.clear();
49 }
50 virtual ~MQwMockable() {
51 fMockDriftAmplitude.clear();
52 fMockDriftFrequency.clear();
53 fMockDriftPhase.clear();
54 }
55
56
57 /// \name Parity mock data generation
58 // @{
59 /// Load the mock data parameters from the current line in the param file.
60 virtual void LoadMockDataParameters(QwParameterFile &paramfile);
61
62 /// Set a single set of harmonic drift parameters
63 void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency);
64 /// Add drift parameters to the internal set
65 void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency);
66 /// Set the normal random event parameters
67 void SetRandomEventParameters(Double_t mean, Double_t sigma);
68 /// Set the helicity asymmetry
69 void SetRandomEventAsymmetry(Double_t asymmetry);
70
71 /// Return a random value generated either from the internal or
72 /// external Random Variable.
73 Double_t GetRandomValue();
74
75 /// Internally generate random event data
76 virtual void RandomizeEventData(int helicity = 0, double time = 0.0) = 0;
77
78//-------------------------------------------------------------------------------------------
79 virtual void SmearByResolution(double resolution) = 0;
80//-------------------------------------------------------------------------------------------
81
82 virtual void SetRawEventData() = 0;
83
84 /// Encode the event data into a CODA buffer
85 virtual void EncodeEventData(std::vector<UInt_t> &buffer) = 0;
86
87 /// Set the flag to use an externally provided random variable
89 /// Set the externally provided random variable
90 void SetExternalRandomVariable(Double_t random_variable) {
92 fExternalRandomVariable = random_variable;
93 };
94
95 // Default the mock data to be calculated with a zero-mean.
97 // @}
98
99 protected:
100 /// \name Parity mock data generation
101 // @{
102 /// Internal randomness generator
103 static boost::mt19937 fRandomnessGenerator;
104 /// Internal normal probability distribution
105 static boost::normal_distribution<double> fNormalDistribution;
106 /// Internal normal random variable
107 static boost::variate_generator
108 < boost::mt19937, boost::normal_distribution<double> > fNormalRandomVariable;
109 /// Flag to use an externally provided normal random variable
111 /// Externally provided normal random variable
113
115
116 // Parameters of the mock data
117 Double_t fMockAsymmetry; ///< Helicity asymmetry
118 Double_t fMockGaussianMean; ///< Mean of normal distribution
119 Double_t fMockGaussianSigma; ///< Sigma of normal distribution
120 std::vector<Double_t> fMockDriftAmplitude; ///< Harmonic drift amplitude
121 std::vector<Double_t> fMockDriftFrequency; ///< Harmonic drift frequency
122 std::vector<Double_t> fMockDriftPhase; ///< Harmonic drift phase
123 // @}
124};
virtual ~MQwMockable()
Definition MQwMockable.h:50
std::vector< Double_t > fMockDriftAmplitude
Harmonic drift amplitude.
double fExternalRandomVariable
Externally provided normal random variable.
std::vector< Double_t > fMockDriftFrequency
Harmonic drift frequency.
Double_t fMockAsymmetry
Helicity asymmetry.
bool fUseExternalRandomVariable
Flag to use an externally provided normal random variable.
void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
Add drift parameters to the internal set.
virtual void EncodeEventData(std::vector< UInt_t > &buffer)=0
Encode the event data into a CODA buffer.
void SetExternalRandomVariable(Double_t random_variable)
Set the externally provided random variable.
Definition MQwMockable.h:90
Double_t fMockGaussianSigma
Sigma of normal distribution.
virtual void RandomizeEventData(int helicity=0, double time=0.0)=0
Internally generate random event data.
void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
Set a single set of harmonic drift parameters.
static boost::variate_generator< boost::mt19937, boost::normal_distribution< double > > fNormalRandomVariable
Internal normal random variable.
Double_t fMockGaussianMean
Mean of normal distribution.
std::vector< Double_t > fMockDriftPhase
Harmonic drift phase.
static boost::normal_distribution< double > fNormalDistribution
Internal normal probability distribution.
void SetRandomEventAsymmetry(Double_t asymmetry)
Set the helicity asymmetry.
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Set the normal random event parameters.
virtual void LoadMockDataParameters(QwParameterFile &paramfile)
Load the mock data parameters from the current line in the param file.
virtual void SetRawEventData()=0
Double_t GetRandomValue()
virtual void SmearByResolution(double resolution)=0
void UseExternalRandomVariable()
Set the flag to use an externally provided random variable.
Definition MQwMockable.h:88
bool fCalcMockDataAsDiff
static boost::mt19937 fRandomnessGenerator
Internal randomness generator.
void SetMockDataAsDiff()
Definition MQwMockable.h:96
Configuration file parser with flexible tokenization and search capabilities.