DDAS Format  1.1.1
A self-contained, lightweight format library and unpacker for DDAS data
DDASHit.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 2016.
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  Author:
11  Ron Fox
12  Jeromy Tompkins
13  Aaron Chester
14  Facility for Rare Isotope Beams
15  Michigan State University
16  East Lansing, MI 48824-1321
17 */
18 
24 #ifndef DDASHIT_H
25 #define DDASHIT_H
26 
27 #include <stdint.h>
28 
29 #include <vector>
30 
32 namespace ddasfmt {
33 
76  class DDASHit {
77 
78  private:
79 
80  // Channel events always have the following info:
81 
82  double m_time;
83  uint64_t m_coarseTime;
84  uint64_t m_externalTimestamp;
85  uint32_t m_timeHigh;
86  uint32_t m_timeLow;
87  uint32_t m_timeCFD;
88  uint32_t m_energy;
89  uint32_t m_finishCode;
90  uint32_t m_channelLength;
91  uint32_t m_channelHeaderLength;
92  uint32_t m_chanID;
93  uint32_t m_slotID;
94  uint32_t m_crateID;
95  uint32_t m_cfdTrigSourceBit;
96  uint32_t m_cfdFailBit;
97  uint32_t m_traceLength;
98  uint32_t m_modMSPS;
99  int m_hdwrRevision;
100  int m_adcResolution;
101  bool m_adcOverflowUnderflow;
102 
103  // Storage for extra data which may be present in a hit:
104 
105  std::vector<uint32_t> m_energySums;
106  std::vector<uint32_t> m_qdcSums;
107  std::vector<uint16_t> m_trace;
108 
109  public:
111  DDASHit();
112 
113  private:
118  void copyIn(const DDASHit& rhs);
119 
120  public:
122  DDASHit(const DDASHit& obj) {
123  copyIn(obj);
124  }
126  DDASHit& operator=(const DDASHit& obj) {
127  if (this != &obj) {
128  copyIn(obj);
129  }
130  return *this;
131  }
138  virtual ~DDASHit();
143  void Reset();
144 
175  double getTime() const { return m_time; }
192  uint64_t getCoarseTime() const { return m_coarseTime; }
202  uint32_t getEnergy() const { return m_energy; }
207  uint32_t getTimeHigh() const { return m_timeHigh; }
212  uint32_t getTimeLow() const { return m_timeLow; }
217  uint32_t getTimeCFD() const { return m_timeCFD; }
224  uint32_t getFinishCode() const { return m_finishCode; }
233  uint32_t getChannelLength() const { return m_channelLength; }
238  uint32_t getChannelHeaderLength() const {
239  return m_channelHeaderLength;
240  }
245  uint32_t getSlotID() const { return m_slotID; }
250  uint32_t getCrateID() const { return m_crateID; }
255  uint32_t getChannelID() const { return m_chanID; }
260  uint32_t getModMSPS() const { return m_modMSPS; }
265  int getHardwareRevision() const { return m_hdwrRevision; }
270  int getADCResolution() const { return m_adcResolution; }
275  uint32_t getCFDTrigSource() const { return m_cfdTrigSourceBit; }
282  uint32_t getCFDFailBit() const { return m_cfdFailBit; }
287  uint32_t getTraceLength() const { return m_traceLength; }
292  std::vector<uint16_t>& getTrace() { return m_trace; }
297  const std::vector<uint16_t>& getTrace() const { return m_trace; }
302  std::vector<uint32_t>& getEnergySums() { return m_energySums; }
307  const std::vector<uint32_t>& getEnergySums() const {
308  return m_energySums;
309  }
314  std::vector<uint32_t>& getQDCSums() { return m_qdcSums; }
319  const std::vector<uint32_t>& getQDCSums() const {
320  return m_qdcSums;
321  }
326  uint64_t getExternalTimestamp() const {
327  return m_externalTimestamp;
328  }
339  bool getADCOverflowUnderflow() const {
340  return m_adcOverflowUnderflow;
341  }
342 
347  void setChannelID(uint32_t channel);
352  void setSlotID(uint32_t slot);
357  void setCrateID(uint32_t crate);
362  void setChannelHeaderLength(uint32_t channelHeaderLength);
367  void setChannelLength(uint32_t channelLength);
372  void setFinishCode(bool finishCode);
377  void setCoarseTime(uint64_t time);
382  void setRawCFDTime(uint32_t data);
387  void setCFDTrigSourceBit(uint32_t bit);
392  void setCFDFailBit(uint32_t bit);
397  void setTimeLow(uint32_t datum);
404  void setTimeHigh(uint32_t datum);
410  void setTime(double compTime);
415  void setEnergy(uint32_t energy);
420  void setTraceLength(uint32_t length);
426  void setModMSPS(uint32_t msps);
432  void setADCResolution(int value);
438  void setHardwareRevision(int value);
443  void appendEnergySum(uint32_t value);
448  void setEnergySums(std::vector<uint32_t> eneSums);
453  void appendQDCSum(uint32_t value);
458  void setQDCSums(std::vector<uint32_t> qdcSums);
463  void appendTraceSample(uint16_t value);
468  void setTrace(std::vector<uint16_t> trace);
474  void setExternalTimestamp(uint64_t value);
480  void setADCOverflowUnderflow(bool state);
481  };
482 
485 } // namespace ddasfmt
486 
487 #endif
Encapsulation of a generic DDAS event.
Definition: DDASHit.h:76
uint32_t getFinishCode() const
Retrieve finish code.
Definition: DDASHit.h:224
void setChannelLength(uint32_t channelLength)
Set the channel length.
Definition: DDASHit.cpp:115
const std::vector< uint16_t > & getTrace() const
Access the trace data.
Definition: DDASHit.h:297
void setTime(double compTime)
Set the hit time.
Definition: DDASHit.cpp:192
void appendQDCSum(uint32_t value)
Append a QDC value to the vector of QDC sums.
Definition: DDASHit.cpp:247
std::vector< uint16_t > & getTrace()
Access the trace data.
Definition: DDASHit.h:292
void setFinishCode(bool finishCode)
Set the finish code.
Definition: DDASHit.cpp:121
void setHardwareRevision(int value)
Set the ADC hardware revision for the ADC which recorded this hit.
Definition: DDASHit.cpp:222
uint32_t getSlotID() const
Retrieve the slot that the module resided in.
Definition: DDASHit.h:245
int getHardwareRevision() const
Retrieve the hardware revision.
Definition: DDASHit.h:265
DDASHit & operator=(const DDASHit &obj)
Assignment operator.
Definition: DDASHit.h:126
void setTimeLow(uint32_t datum)
Set the lower 32 bits of the 48-bit timestamp.
Definition: DDASHit.cpp:180
uint32_t getChannelHeaderLength() const
Retrieve length of header in original data packet.
Definition: DDASHit.h:238
void appendTraceSample(uint16_t value)
Append a 16-bit ADC trace sample to the trace vector.
Definition: DDASHit.cpp:266
void setADCOverflowUnderflow(bool state)
Set ADC over- or under-flow state.
Definition: DDASHit.cpp:285
void setTrace(std::vector< uint16_t > trace)
Set the trace data from an existing trace.
Definition: DDASHit.cpp:272
void setRawCFDTime(uint32_t data)
Set the raw CFD time.
Definition: DDASHit.cpp:146
uint32_t getEnergy() const
Retrieve the energy.
Definition: DDASHit.h:202
void setCoarseTime(uint64_t time)
Set the coarse timestamp.
Definition: DDASHit.cpp:140
void setModMSPS(uint32_t msps)
Set the value of the ADC frequency in MSPS for the ADC which recorded this hit.
Definition: DDASHit.cpp:210
const std::vector< uint32_t > & getEnergySums() const
Access the energy/baseline sum data.
Definition: DDASHit.h:307
bool getADCOverflowUnderflow() const
Retrieve the ADC overflow/underflow status.
Definition: DDASHit.h:339
uint64_t getCoarseTime() const
Retrieve the 48-bit timestamp in nanoseconds without any CFD correction.
Definition: DDASHit.h:192
uint32_t getCFDTrigSource() const
Retrieve trigger source bit from CFD data.
Definition: DDASHit.h:275
uint32_t getCrateID() const
Retrieve the index of the crate the module resided in.
Definition: DDASHit.h:250
void appendEnergySum(uint32_t value)
Set the crate ID.
Definition: DDASHit.cpp:228
uint32_t getModMSPS() const
Retrieve the ADC frequency of the module.
Definition: DDASHit.h:260
uint64_t getExternalTimestamp() const
Retrieve the external timestamp.
Definition: DDASHit.h:326
DDASHit(const DDASHit &obj)
Copy constructor.
Definition: DDASHit.h:122
std::vector< uint32_t > & getQDCSums()
Access the QDC data.
Definition: DDASHit.h:314
uint32_t getChannelID() const
Retrieve the channel index.
Definition: DDASHit.h:255
uint32_t getTimeHigh() const
Retrieve most significant 16-bits of raw timestamp.
Definition: DDASHit.h:207
DDASHit()
Default constructor.
Definition: DDASHit.cpp:40
void Reset()
Resets the state of all member data to that of initialization.
Definition: DDASHit.cpp:57
void setCrateID(uint32_t crate)
Set the crate ID.
Definition: DDASHit.cpp:103
void setExternalTimestamp(uint64_t value)
Set the value of the external timestamp.
Definition: DDASHit.cpp:279
void setEnergySums(std::vector< uint32_t > eneSums)
Set the energy sum data from an existing set of sums.
Definition: DDASHit.cpp:234
void setChannelID(uint32_t channel)
Set the channel ID.
Definition: DDASHit.cpp:91
void setEnergy(uint32_t energy)
Set the energy for this hit.
Definition: DDASHit.cpp:198
uint32_t getTimeCFD() const
Retrieve the raw CFD time.
Definition: DDASHit.h:217
void setTimeHigh(uint32_t datum)
Set the higher 16 bits of the 48-bit timestamp.
Definition: DDASHit.cpp:186
virtual ~DDASHit()
Destructor.
Definition: DDASHit.cpp:87
uint32_t getChannelLength() const
Retrieve number of 32-bit words that were in original data packet.
Definition: DDASHit.h:233
uint32_t getTraceLength() const
Retrieve trace length.
Definition: DDASHit.h:287
std::vector< uint32_t > & getEnergySums()
Access the energy/baseline sum data.
Definition: DDASHit.h:302
void setQDCSums(std::vector< uint32_t > qdcSums)
Set the QDC sum data from an existing set of sums.
Definition: DDASHit.cpp:253
void setChannelHeaderLength(uint32_t channelHeaderLength)
Set the channel header length.
Definition: DDASHit.cpp:109
void setSlotID(uint32_t slot)
Set the slot ID.
Definition: DDASHit.cpp:97
void setADCResolution(int value)
Set the value of the ADC resolution (bit depth) for the ADC which recorded this hit.
Definition: DDASHit.cpp:216
void setTraceLength(uint32_t length)
Set the ADC trace length.
Definition: DDASHit.cpp:204
double getTime() const
Retrieve computed time.
Definition: DDASHit.h:175
int getADCResolution() const
Retrieve the ADC resolution.
Definition: DDASHit.h:270
uint32_t getCFDFailBit() const
Retreive failure bit from CFD data.
Definition: DDASHit.h:282
void setCFDTrigSourceBit(uint32_t bit)
Set the CFD trigger source bit.
Definition: DDASHit.cpp:161
void setCFDFailBit(uint32_t bit)
Set the CFD fail bit.
Definition: DDASHit.cpp:174
uint32_t getTimeLow() const
Retrieve least significant 32-bit of raw timestamp.
Definition: DDASHit.h:212
const std::vector< uint32_t > & getQDCSums() const
Access the QDC data.
Definition: DDASHit.h:319