ROOTANA
UnpackVF48A.h
Go to the documentation of this file.
1 // UnpackVF48A.h
2 
3 #ifndef UnpackVF48A_H
4 #define UnpackVF48A_H
5 
6 #include <stdint.h>
7 #include <deque>
8 
9 #define VF48_MAX_MODULES 22
10 #define VF48_MAX_GROUPS 6
11 #define VF48_MAX_CHANNELS 48
12 #define VF48_MAX_SAMPLES 1100
13 
15 {
16  int channel;
17  uint32_t time;
18  uint32_t charge;
19  bool complete;
22 };
23 
24 struct VF48module
25 {
26  int unit;
27  uint32_t trigger;
28  int error;
29  int tgroup;
34  uint32_t groupMask;
36  bool complete;
37  //int numSamples;
38  //int numChannels;
39  int presentMask[VF48_MAX_GROUPS]; // mask of channels present in the data
40  int hitMask[VF48_MAX_GROUPS]; // mask of channels that have hits detected by firmware
42 
43  VF48module(int i); // ctor
44 
45  void PrintModule() const;
46 };
47 
48 struct VF48event
49 {
50  int eventNo;
51  int complete;
52  int error;
53  uint32_t modulesMask;
54  double timestamp;
56 
57  VF48event(int eventNo); // ctor
58 
59  ~VF48event(); // dtor
60 
61  void PrintSummary() const;
62  void PrintEvent() const;
63 };
64 
66 {
67  public:
68  UnpackVF48(); // ctor
69  ~UnpackVF48(); // dtor
70 
71  void Reset();
72 
73  void UnpackStream(int module, const void* data_ptr, int data_size);
74  VF48event* GetEvent(bool flush=false);
75 
76  void SetNumModules(int num_modules);
77  void SetModulesMask(uint32_t mask);
78  void SetGroupEnableMask(int module, int grp_enable_mask);
79  void SetNumSamples(int module, int num_samples);
80 
81  void SetDisasm(bool stream, bool structure, bool samples);
82 
83  void SetCoincTime(double time_sec);
84  void SetTimestampResync(bool enable);
85  void SetTsFreq(int module, double ts_freq_hz);
86  void SetChanEnable(int module, int grp, int chan_enable);
87  void SetFlushIncompleteThreshold(int threshold);
88 
89  double GetTsFreq(int module);
90 
91  public:
93  uint32_t fModulesMask;
98  double fCoinc;
100 
104 
106 
107  int fEventNo;
109 
110  // buffer of pending events
111  std::deque<VF48event*> fBuffer;
112 
113  // buffer of stream data
120 
121  // timestamps
124 
125  private:
126  void UnpackEvent(int module, int group, const uint32_t* data, int wcount);
127  VF48event* FindEvent(int unit, double timestamp, bool dup = false);
128  VF48module* FindModule(int unit, int group, double timestamp);
129  void AddToEvent(VF48module* m);
130  void CompleteModule(VF48module* m);
131  void CompleteEvent(VF48event* e);
132  void ResetEventBuffer();
133  void ResetStreamBuffer();
134  void PrintAllEvents();
135  int NewGroup(int unit);
136 };
137 
138 #endif
139 // end
#define VF48_MAX_SAMPLES
Definition: UnpackVF48A.h:12
#define VF48_MAX_MODULES
Definition: UnpackVF48A.h:9
#define VF48_MAX_CHANNELS
Definition: UnpackVF48A.h:11
#define VF48_MAX_GROUPS
Definition: UnpackVF48A.h:10
void SetNumModules(int num_modules)
bool fDisasmStream
Definition: UnpackVF48A.h:101
void UnpackEvent(int module, int group, const uint32_t *data, int wcount)
void SetTsFreq(int module, double ts_freq_hz)
bool wacc[VF48_MAX_MODULES][VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:118
bool fChanEnabled[VF48_MAX_MODULES][VF48_MAX_CHANNELS]
Definition: UnpackVF48A.h:95
unsigned fFlushIncompleteThreshold
Definition: UnpackVF48A.h:99
void CompleteModule(VF48module *m)
bool fDisasmSamples
Definition: UnpackVF48A.h:103
VF48event * FindEvent(int unit, double timestamp, bool dup=false)
void SetChanEnable(int module, int grp, int chan_enable)
void CompleteEvent(VF48event *e)
void SetNumSamples(int module, int num_samples)
int wgrp[VF48_MAX_MODULES]
Definition: UnpackVF48A.h:114
int NewGroup(int unit)
VF48module * FindModule(int unit, int group, double timestamp)
double fCoinc
Definition: UnpackVF48A.h:98
int wdiscarded[VF48_MAX_MODULES]
Definition: UnpackVF48A.h:119
void SetModulesMask(uint32_t mask)
void SetTimestampResync(bool enable)
int wptr[VF48_MAX_MODULES][VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:116
double GetTsFreq(int module)
bool fTimestampResyncEnable
Definition: UnpackVF48A.h:105
void SetFlushIncompleteThreshold(int threshold)
void PrintAllEvents()
void UnpackStream(int module, const void *data_ptr, int data_size)
int fNumModules
Definition: UnpackVF48A.h:92
uint32_t fModulesMask
Definition: UnpackVF48A.h:93
uint64_t ts_first[VF48_MAX_MODULES][VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:122
void ResetStreamBuffer()
void SetCoincTime(double time_sec)
double fFreq[VF48_MAX_MODULES]
Definition: UnpackVF48A.h:97
int fNumSamples[VF48_MAX_MODULES]
Definition: UnpackVF48A.h:96
uint32_t fGroupEnabled[VF48_MAX_MODULES]
Definition: UnpackVF48A.h:94
void AddToEvent(VF48module *m)
uint32_t * wbuf[VF48_MAX_MODULES][VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:117
bool fDisasmStructure
Definition: UnpackVF48A.h:102
void SetDisasm(bool stream, bool structure, bool samples)
void SetGroupEnableMask(int module, int grp_enable_mask)
void ResetEventBuffer()
uint64_t ts_last[VF48_MAX_MODULES][VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:123
VF48event * GetEvent(bool flush=false)
int fBadDataCount
Definition: UnpackVF48A.h:108
std::deque< VF48event * > fBuffer
Definition: UnpackVF48A.h:111
void Reset()
int wmax[VF48_MAX_MODULES][VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:115
bool complete
Definition: UnpackVF48A.h:19
int numSamples
Definition: UnpackVF48A.h:20
uint32_t time
Definition: UnpackVF48A.h:17
uint32_t charge
Definition: UnpackVF48A.h:18
uint16_t samples[VF48_MAX_SAMPLES]
Definition: UnpackVF48A.h:21
void PrintSummary() const
Definition: UnpackVF48A.cxx:83
VF48module * modules[VF48_MAX_MODULES]
Definition: UnpackVF48A.h:55
VF48event(int eventNo)
Definition: UnpackVF48A.cxx:60
int eventNo
Definition: UnpackVF48A.h:50
double timestamp
Definition: UnpackVF48A.h:54
int complete
Definition: UnpackVF48A.h:51
void PrintEvent() const
uint32_t modulesMask
Definition: UnpackVF48A.h:53
VF48channel channels[VF48_MAX_CHANNELS]
Definition: UnpackVF48A.h:41
VF48module(int i)
Definition: UnpackVF48A.cxx:14
uint32_t completeGroupMask
Definition: UnpackVF48A.h:35
uint64_t timestamp64[VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:31
double timestamps[VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:32
int presentMask[VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:39
uint32_t timestampGroupMask
Definition: UnpackVF48A.h:30
int hitMask[VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:40
void PrintModule() const
Definition: UnpackVF48A.cxx:43
uint32_t trigno[VF48_MAX_GROUPS]
Definition: UnpackVF48A.h:33
uint32_t trigger
Definition: UnpackVF48A.h:27
uint32_t groupMask
Definition: UnpackVF48A.h:34
bool complete
Definition: UnpackVF48A.h:36