13 #include <boost/random.hpp>
43 std::ostringstream stream;
48 int main(
int argc,
char* argv[])
92 std::vector<std::string> bcm_name;
93 std::vector<double> bcm_asym;
94 double bcm_mean, bcm_sigma;
95 bcm_mean = 2.5e7; bcm_sigma = 2.5e6;
96 bcm_name.push_back(
"qwk_bcm0l00"); bcm_asym.push_back(0.0
e-0);
97 bcm_name.push_back(
"qwk_bcm0l01"); bcm_asym.push_back(1.0
e-1);
98 bcm_name.push_back(
"qwk_bcm0l02"); bcm_asym.push_back(2.0
e-2);
99 bcm_name.push_back(
"qwk_bcm0l03"); bcm_asym.push_back(3.0
e-3);
100 bcm_name.push_back(
"qwk_bcm0l04"); bcm_asym.push_back(4.0
e-4);
101 bcm_name.push_back(
"qwk_bcm0l05"); bcm_asym.push_back(5.0
e-5);
102 bcm_name.push_back(
"qwk_bcm0l06"); bcm_asym.push_back(6.0
e-6);
103 bcm_name.push_back(
"qwk_bcm0l07"); bcm_asym.push_back(7.0
e-7);
104 for (
unsigned int i = 0; i < bcm_name.size(); i++) {
119 std::vector<std::string> bpm_name;
120 std::vector<double> bpm_asym, bpm_meanX, bpm_sigmaX, bpm_meanY, bpm_sigmaY;
121 bpm_name.push_back(
"qwk_0r06"); bpm_asym.push_back(1.0
e-3);
122 bpm_name.push_back(
"qwk_0l06"); bpm_asym.push_back(1.0
e-3);
123 bpm_meanX.push_back(6.0); bpm_sigmaX.push_back(3.0
e-3);
124 bpm_meanX.push_back(6.0); bpm_sigmaX.push_back(3.0
e-3);
125 bpm_meanY.push_back(-1.5); bpm_sigmaY.push_back(4.0
e-3);
126 bpm_meanY.push_back(-1.5); bpm_sigmaY.push_back(4.0
e-3);
127 for (
unsigned int i = 0; i < 2; i++) {
138 Double_t bar_mean = 2.0e7;
139 Double_t bar_sigma = 3.0e4;
140 Double_t bar_asym = 4.0e-4;
175 Double_t lumi_mean = 2.5e7;
176 Double_t lumi_sigma = 2.5e6;
177 Double_t lumi_asym = 1.0e-7;
189 boost::mt19937 randomnessGenerator(999);
190 boost::normal_distribution<double> normalDistribution;
191 boost::variate_generator
192 < boost::mt19937, boost::normal_distribution<double> >
193 normal(randomnessGenerator, normalDistribution);
204 for (UInt_t run = runnumber_min;
205 run <= runnumber_max;
210 TString filename = Form(
"QwMock_%u.log", run);
211 if (eventbuffer.
OpenDataFile(filename,
"W") != CODA_OK) {
212 std::cout <<
"Error: could not open file!" << std::endl;
225 unsigned int seed = 0x1234 ^ run;
230 if (
kDebug) std::cout <<
"Starting event loop..." << std::endl;
235 if (abs(eventnumber_max - eventnumber_min) < 10)
236 QwWarning <<
"Only " << abs(eventnumber_max - eventnumber_min)
240 for (Int_t event = eventnumber_min;
event <= eventnumber_max;
event++) {
258 else std::cout <<
"?";
262 else std::cout <<
"(?) ";
270 double helicity_window =
Qw::ms;
271 double time =
event * helicity_window;
288 if (fmod(time, period) >= period - length) {
291 double scale = double(period - fmod(time, period)) / double(length);
296 if (fmod(time, period) < helicity_window) {
332 for (
int var = 0; var <
NVARS; var++) {
337 C[0][0] = 1.0; C[0][1] = 0.5; C[0][2] = 0.5;
338 C[1][0] = 0.0; C[1][1] = 1.32288; C[1][2] = 0.03780;
339 C[2][0] = 0.0; C[2][1] = 0.0; C[2][2] = 1.11739;
340 for (
int i = 0; i <
NVARS; i++)
341 for (
int j = 0; j <
NVARS; j++)
342 x[i] += C[j][i] * z[j];
359 if ((
kDebug && event % 1000 == 0)
360 || event % 10000 == 0)
361 std::cout <<
"Generated " <<
event <<
" events." << std::endl;
int GetIntValuePairFirst(const std::string &key)
Get the first of a pair of integer values.
virtual void SetRandomEventAsymmetry(Double_t asymmetry)=0
static const double ms
Time units: base unit is ms.
#define QwMessage
Predefined log drain for regular messages.
static void AppendToSearchPath(const TString &searchdir)
Add a directory to the search path.
void SetFirstBits(UInt_t nbits, UInt_t firstbits)
static const double Hz
Frequency units: base unit is kHz.
void SetRandomEventAsymmetry(Double_t asymmetry)
void DefineOptionsParity(QwOptions &options)
void ResetControlParameters()
void ProcessOptions(QwOptions &options)
Process configuration options (default behavior)
virtual void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY)
UInt_t GetRandomSeedActual()
Int_t OpenDataFile(UInt_t current_run, Short_t seg)
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Int_t EncodePrestartEvent(int runnumber, int runtype=0)
Int_t GetHelicityDelayed()
Virtual base class for the parity subsystems.
VQwBCM * GetBCM(const TString name)
void SetConfigFile(const std::string &configfile)
Set a configuration file.
A logfile class, based on an identical class in the Hermes analyzer.
Int_t EncodeSubsystemData(QwSubsystemArray &subsystems)
Load the options for the parity subsystems.
static const bool kBeamTrips
static const int kMultiplet
virtual void SetRandomEventParameters(Double_t mean, Double_t sigma)=0
std::string stringify(int i)
void SetEventPatternPhase(Int_t event, Int_t pattern, Int_t phase)
virtual void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)=0
void SetRandomEventParameters(Double_t mean, Double_t sigma)
UInt_t GetRandomSeedDelayed()
static std::ostream & endl(std::ostream &)
End of the line.
const std::string getenv_safe_string(const char *name)
void SetRandomEventAsymmetry(Double_t asymmetry)
VQwSubsystemParity * GetSubsystemByName(const TString &name)
Get the subsystem with the specified name.
#define QwWarning
Predefined log drain for warnings.
Int_t GetHelicityActual()
int main(int argc, char **argv)
VQwBPM * GetBPMStripline(const TString name)
int GetIntValuePairLast(const std::string &key)
Get the last of a pair of integer values.
void RandomizeEventData(int helicity=0, double time=0.0)
Randomize the data in this event.
void SetCommandLine(int argc, char *argv[], bool default_config_file=true)
Set the command line arguments.