-
Notifications
You must be signed in to change notification settings - Fork 14
/
f1724.hh
98 lines (87 loc) · 2.9 KB
/
f1724.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef _F1724_HH_
#define _F1724_HH_
#include "V1724.hh"
#include "Options.hh"
#include <random>
#include <tuple>
#include <mutex>
#include <condition_variable>
#include <thread>
class f1724 : public V1724 {
public:
f1724(std::shared_ptr<MongoLog>&, std::shared_ptr<Options>&, int, int, int, unsigned);
virtual ~f1724();
virtual int Read(std::unique_ptr<data_packet>&);
virtual int WriteRegister(unsigned, unsigned);
virtual unsigned ReadRegister(unsigned);
virtual int End();
virtual int SINStart();
virtual int SoftwareStart();
virtual int AcquisitionStop(bool);
virtual int SWTrigger();
virtual int Reset();
virtual bool EnsureReady(int, int) {return sRun || sReady;}
virtual bool EnsureStarted(int, int) {return sRun == true;}
virtual bool EnsureStopped(int, int) {return sRun == false;}
virtual int CheckErrors() {return 0;}
virtual uint32_t GetAcquisitionStatus();
protected:
struct hit_t {
int pmt_i;
double time;
};
struct pmt_pos_t {
double x;
double y;
int array;
};
static void GlobalRun();
static void GlobalInit(fax_options_t&, std::shared_ptr<MongoLog>&);
static void GlobalDeinit();
static std::tuple<double, double, double> GenerateEventLocation();
static std::vector<int> GenerateEventSize(double, double, double);
static std::vector<hit_t> MakeHitpattern(int, int, double, double, double);
static void SendToWorkers(const std::vector<hit_t>&, long);
static pmt_pos_t PMTiToXY(int);
static std::thread sGeneratorThread;
static std::mutex sMutex;
static std::random_device sRD;
static std::mt19937_64 sGen;
static std::uniform_real_distribution<> sFlatDist;
static long sClock;
static int sEventCounter;
static std::atomic_bool sRun;
static std::atomic_bool sReady;
static fax_options_t sFaxOptions;
static int sNumPMTs;
static std::vector<f1724*> sRegistry;
static std::vector<pmt_pos_t> sPMTxy;
static std::condition_variable sCV;
static std::shared_ptr<MongoLog> sLog;
virtual int Init(int, int, std::shared_ptr<Options>&);
void Run();
virtual int GetClockCounter(uint32_t);
void MakeWaveform(std::vector<hit_t>&, long);
void ConvertToDigiFormat(const std::vector<std::vector<double>>&, int, long);
std::vector<std::vector<double>> GenerateNoise(int, int=0xFF);
void ReceiveFromGenerator(std::vector<hit_t>, long);
std::u32string fBuffer;
std::mutex fBufferMutex;
std::atomic_int fBufferSize;
std::random_device fRD;
std::mt19937_64 fGen;
std::uniform_real_distribution<> fFlatDist;
std::vector<double> fSPEtemplate;
std::vector<double> fBLoffset, fBLslope;
std::vector<double> fNoiseRMS;
std::vector<double> fBaseline;
fax_options_t fFaxOptions;
std::atomic_long fTimestamp;
std::atomic_int fEventCounter;
std::vector<hit_t> fProtoPulse;
std::condition_variable fCV;
std::mutex fMutex;
std::thread fGeneratorThread;
bool fSeenUnder5, fSeenOver15;
};
#endif // _F1724_HH_ defined