NSCL DDAS  12.1-001
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 
30 namespace ddasfmt {
31  class DDASHit;
32 }
33 namespace ufmt {
34  class RingItemFactoryBase;
35 }
36 
37 namespace DAQ {
38  namespace DDAS {
39 
120  {
121  private:
122  std::string m_fname;
123  int m_fd;
124  ufmt::RingItemFactoryBase* m_pFactory;
125  std::vector<uint32_t> m_evtBuf;
126  std::time_t m_start;
127  std::time_t m_stop;
128 
129  public:
136  DDASDataSimulator(std::string fname, int version);
137 
142  void beginRun();
147  void endRun();
160  void putHit(
161  const ddasfmt::DDASHit& hit, int sourceID=0,
162  bool useExtTS=false, double cal=0.0
163  );
164 
169  void setBuffer(const ddasfmt::DDASHit& hit);
175  std::vector<uint32_t> getBuffer() { return m_evtBuf; }
177  void dumpBuffer();
178 
179  private:
185  void setWord0(const ddasfmt::DDASHit& hit);
194  void setWords1And2(const ddasfmt::DDASHit& hit);
200  void setWord3(const ddasfmt::DDASHit& hit);
201 
206  void setExternalTS(const ddasfmt::DDASHit& hit);
211  void setEnergySums(const ddasfmt::DDASHit& hit);
216  void setQDCSums(const ddasfmt::DDASHit& hit);
221  void setTraceData(const ddasfmt::DDASHit& hit);
222 
228  uint32_t getHeaderLength(const ddasfmt::DDASHit& hit);
234  uint32_t getModInfoWord(const ddasfmt::DDASHit& hit);
240  uint64_t getCoarseTimestamp(const ddasfmt::DDASHit& hit);
247  int getClockPeriod(const ddasfmt::DDASHit& hit);
254  int getSamplePeriod(const ddasfmt::DDASHit& hit);
260  uint32_t getPackedCFDResult(
261  const ddasfmt::DDASHit& hit, double corr
262  );
263  };
264 
267  } // namespace DDAS.
268 } // namespace DAQ.
269 
270 #endif
Simulates data produced by a DDAS readout program in user code.
Definition: DDASDataSimulator.h:120
DDASDataSimulator(std::string fname, int version)
Constructor.
Definition: DDASDataSimulator.cpp:85
void setBuffer(const ddasfmt::DDASHit &hit)
Set the data buffer from a DDASHit.
Definition: DDASDataSimulator.cpp:227
void endRun()
End a simulated run.
Definition: DDASDataSimulator.cpp:139
void dumpBuffer()
Formatted dump of data buffer to stdout.
Definition: DDASDataSimulator.cpp:277
std::vector< uint32_t > getBuffer()
Get the data buffer.
Definition: DDASDataSimulator.h:175
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:178
void beginRun()
Begin a simulated run.
Definition: DDASDataSimulator.cpp:101
Definition: RootFileDataSink.h:31
Definition: DataSource.h:27