NSCL DDAS 12.2-009
Support for XIA DDAS at FRIB
DDASDataSimulator.h
Go to the documentation of this file.
1/*
2 This software is Copyright by the Board of Trustees of Michigan
3 State University (c) Copyright 2017.
4
5 You may use this software under the terms of the GNU public license
6 (GPL). The terms of this license are described at:
7
8 http://www.gnu.org/licenses/gpl.txt
9
10 Authors:
11 Aaron Chester
12 FRIB
13 Michigan State University
14 East Lansing, MI 48824-1321
15*/
16
22#ifndef DDASDATASIMULATOR_H
23#define DDASDATASIMULATOR_H
24
25#include <cstdint>
26#include <ctime>
27#include <string>
28#include <vector>
29
30namespace ddasfmt {
31class DDASHit;
32}
33namespace ufmt {
34class RingItemFactoryBase;
35}
36
37namespace DAQ {
38namespace DDAS {
39
133private:
134 std::string m_fname;
135 int m_fd;
136 ufmt::RingItemFactoryBase *m_pFactory;
137 std::vector<uint32_t> m_evtBuf;
138 std::time_t m_start;
139 std::time_t m_stop;
140
141public:
148 DDASDataSimulator(std::string fname, int version);
149
155 void beginRun(int sourceID = 0);
161 void endRun(int sourceID = 0);
175 void putHit(const ddasfmt::DDASHit &hit, int sourceID = 0,
176 bool useExtTS = false, double cal = 0.0);
177
182 void setBuffer(const ddasfmt::DDASHit &hit);
188 std::vector<uint32_t> getBuffer() { return m_evtBuf; }
190 void dumpBuffer();
191
192private:
199 void setWord0(const ddasfmt::DDASHit &hit);
207 void setWords1And2(const ddasfmt::DDASHit &hit);
213 void setWord3(const ddasfmt::DDASHit &hit);
214
219 void setExternalTS(const ddasfmt::DDASHit &hit);
224 void setEnergySums(const ddasfmt::DDASHit &hit);
229 void setQDCSums(const ddasfmt::DDASHit &hit);
234 void setTraceData(const ddasfmt::DDASHit &hit);
235
241 uint32_t getHeaderLength(const ddasfmt::DDASHit &hit);
247 uint32_t getModInfoWord(const ddasfmt::DDASHit &hit);
253 uint64_t getCoarseTimestamp(const ddasfmt::DDASHit &hit);
260 int getClockPeriod(const ddasfmt::DDASHit &hit);
267 int getSamplePeriod(const ddasfmt::DDASHit &hit);
273 uint32_t getPackedCFDResult(const ddasfmt::DDASHit &hit, double corr);
274};
275
278} // namespace DDAS.
279} // namespace DAQ.
280
281#endif
Simulates data produced by a DDAS readout program in user code.
Definition: DDASDataSimulator.h:132
DDASDataSimulator(std::string fname, int version)
Constructor.
Definition: DDASDataSimulator.cpp:84
void setBuffer(const ddasfmt::DDASHit &hit)
Set the data buffer from a DDASHit.
Definition: DDASDataSimulator.cpp:237
void endRun(int sourceID=0)
End a simulated run.
Definition: DDASDataSimulator.cpp:132
std::vector< uint32_t > getBuffer()
Get the data buffer.
Definition: DDASDataSimulator.h:188
void dumpBuffer()
Formatted dump of data buffer to stdout.
Definition: DDASDataSimulator.cpp:284
void beginRun(int sourceID=0)
Begin a simulated run.
Definition: DDASDataSimulator.cpp:98
void putHit(const ddasfmt::DDASHit &hit, int sourceID=0, bool useExtTS=false, double cal=0.0)
Write a hit to the output file. This is the normal way users will add simulated data to the output.
Definition: DDASDataSimulator.cpp:166
Definition: RootFileDataSink.h:31
Definition: DataSource.h:28