DDAS Format 2.1.0
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
32namespace ddasfmt {
33
76class DDASHit {
77
78private:
79 // Channel events always have the following info:
80
81 double m_time;
82 uint64_t m_coarseTime;
83 uint64_t m_externalTimestamp;
84 uint32_t m_timeHigh;
85 uint32_t m_timeLow;
86 uint32_t m_timeCFD;
87 uint32_t m_energy;
88 uint32_t m_finishCode;
89 uint32_t m_channelLength;
90 uint32_t m_channelHeaderLength;
91 uint32_t m_chanID;
92 uint32_t m_slotID;
93 uint32_t m_crateID;
94 uint32_t m_cfdTrigSourceBit;
95 uint32_t m_cfdFailBit;
96 uint32_t m_traceLength;
97 uint32_t m_modMSPS;
98 uint16_t m_hdwrRevision;
99 uint16_t m_adcResolution;
100 bool m_adcOverflowUnderflow;
101
102 // Storage for extra data which may be present in a hit:
103
104 std::vector<uint32_t> m_energySums;
105 std::vector<uint32_t> m_qdcSums;
106 std::vector<uint16_t> m_trace;
107
108public:
110 DDASHit();
111
118 virtual ~DDASHit() {};
123 void Reset();
124
155 double getTime() const { return m_time; }
172 uint64_t getCoarseTime() const { return m_coarseTime; }
182 uint32_t getEnergy() const { return m_energy; }
187 uint32_t getTimeHigh() const { return m_timeHigh; }
192 uint32_t getTimeLow() const { return m_timeLow; }
197 uint32_t getTimeCFD() const { return m_timeCFD; }
204 uint32_t getFinishCode() const { return m_finishCode; }
213 uint32_t getChannelLength() const { return m_channelLength; }
218 uint32_t getChannelHeaderLength() const { return m_channelHeaderLength; }
223 uint32_t getSlotID() const { return m_slotID; }
228 uint32_t getCrateID() const { return m_crateID; }
233 uint32_t getChannelID() const { return m_chanID; }
238 uint32_t getModMSPS() const { return m_modMSPS; }
243 uint16_t getHardwareRevision() const { return m_hdwrRevision; }
248 uint16_t getADCResolution() const { return m_adcResolution; }
253 uint32_t getCFDTrigSource() const { return m_cfdTrigSourceBit; }
260 uint32_t getCFDFailBit() const { return m_cfdFailBit; }
265 uint32_t getTraceLength() const { return m_traceLength; }
270 std::vector<uint16_t> &getTrace() { return m_trace; }
275 const std::vector<uint16_t> &getTrace() const { return m_trace; }
280 std::vector<uint32_t> &getEnergySums() { return m_energySums; }
285 const std::vector<uint32_t> &getEnergySums() const { return m_energySums; }
290 std::vector<uint32_t> &getQDCSums() { return m_qdcSums; }
295 const std::vector<uint32_t> &getQDCSums() const { return m_qdcSums; }
300 uint64_t getExternalTimestamp() const { return m_externalTimestamp; }
307 bool getADCOverflowUnderflow() const { return m_adcOverflowUnderflow; }
308
313 void setChannelID(uint32_t channel) { m_chanID = channel; }
318 void setSlotID(uint32_t slot) { m_slotID = slot; }
323 void setCrateID(uint32_t crate) { m_crateID = crate; }
328 void setChannelHeaderLength(uint32_t channelHeaderLength) {
329 m_channelHeaderLength = channelHeaderLength;
330 }
335 void setChannelLength(uint32_t channelLength) {
336 m_channelLength = channelLength;
337 }
342 void setFinishCode(bool finishCode) { m_finishCode = finishCode; }
358 void setCoarseTime(uint64_t time) { m_coarseTime = time; }
363 void setRawCFDTime(uint32_t data) { m_timeCFD = data; }
364
376 void setCFDTrigSourceBit(uint32_t bit) { m_cfdTrigSourceBit = bit; }
377
387 void setCFDFailBit(uint32_t bit) { m_cfdFailBit = bit; }
392 void setTimeLow(uint32_t datum) { m_timeLow = datum; }
399 void setTimeHigh(uint32_t datum);
405 void setTime(double compTime) { m_time = compTime; }
410 void setEnergy(uint32_t energy) { m_energy = energy; }
415 void setTraceLength(uint32_t length) { m_traceLength = length; }
421 void setModMSPS(uint32_t msps) { m_modMSPS = msps; }
427 void setADCResolution(uint16_t value) { m_adcResolution = value; }
433 void setHardwareRevision(uint16_t value) { m_hdwrRevision = value; }
438 void appendEnergySum(uint32_t value) { m_energySums.push_back(value); }
443 void setEnergySums(std::vector<uint32_t> eneSums);
448 void appendQDCSum(uint32_t value) { m_qdcSums.push_back(value); }
453 void setQDCSums(std::vector<uint32_t> qdcSums);
458 void appendTraceSample(uint16_t value) { m_trace.push_back(value); }
463 void setTrace(std::vector<uint16_t> trace) {
464 m_trace = std::move(trace);
465 setTraceLength(m_trace.size());
466 }
472 void setExternalTimestamp(uint64_t value) { m_externalTimestamp = value; }
478 void setADCOverflowUnderflow(bool state) { m_adcOverflowUnderflow = state; }
479};
480
483} // namespace ddasfmt
484
485#endif
Encapsulation of a generic DDAS event.
Definition: DDASHit.h:76
uint32_t getFinishCode() const
Retrieve finish code.
Definition: DDASHit.h:204
void setChannelLength(uint32_t channelLength)
Set the channel length.
Definition: DDASHit.h:335
void setTime(double compTime)
Set the hit time.
Definition: DDASHit.h:405
void appendQDCSum(uint32_t value)
Append a QDC value to the vector of QDC sums.
Definition: DDASHit.h:448
const std::vector< uint32_t > & getEnergySums() const
Access the energy/baseline sum data.
Definition: DDASHit.h:285
void setFinishCode(bool finishCode)
Set the finish code.
Definition: DDASHit.h:342
uint32_t getSlotID() const
Retrieve the slot that the module resided in.
Definition: DDASHit.h:223
uint16_t getADCResolution() const
Retrieve the ADC resolution.
Definition: DDASHit.h:248
std::vector< uint32_t > & getQDCSums()
Access the QDC data.
Definition: DDASHit.h:290
void setTimeLow(uint32_t datum)
Set the lower 32 bits of the 48-bit timestamp.
Definition: DDASHit.h:392
uint32_t getChannelHeaderLength() const
Retrieve length of header in original data packet.
Definition: DDASHit.h:218
void appendTraceSample(uint16_t value)
Append a 16-bit ADC trace sample to the trace vector.
Definition: DDASHit.h:458
void setADCOverflowUnderflow(bool state)
Set ADC over- or under-flow state.
Definition: DDASHit.h:478
void setTrace(std::vector< uint16_t > trace)
Set the trace data from an existing trace.
Definition: DDASHit.h:463
void setRawCFDTime(uint32_t data)
Set the raw CFD time.
Definition: DDASHit.h:363
uint32_t getEnergy() const
Retrieve the energy.
Definition: DDASHit.h:182
void setCoarseTime(uint64_t time)
Set the coarse timestamp (timestamp without CFD correction).
Definition: DDASHit.h:358
void setModMSPS(uint32_t msps)
Set the value of the ADC frequency in MSPS for the ADC which recorded this hit.
Definition: DDASHit.h:421
bool getADCOverflowUnderflow() const
Retrieve the ADC overflow/underflow status.
Definition: DDASHit.h:307
uint64_t getCoarseTime() const
Retrieve the raw timestamp in nanoseconds without any CFD correction.
Definition: DDASHit.h:172
uint32_t getCFDTrigSource() const
Retrieve trigger source bit from CFD data.
Definition: DDASHit.h:253
uint32_t getCrateID() const
Retrieve the index of the crate the module resided in.
Definition: DDASHit.h:228
virtual ~DDASHit()
Destructor.
Definition: DDASHit.h:118
void appendEnergySum(uint32_t value)
Append energy sum value to the vector of energy sums.
Definition: DDASHit.h:438
uint32_t getModMSPS() const
Retrieve the ADC frequency of the module.
Definition: DDASHit.h:238
uint64_t getExternalTimestamp() const
Retrieve the external timestamp.
Definition: DDASHit.h:300
const std::vector< uint16_t > & getTrace() const
Access the trace data.
Definition: DDASHit.h:275
void setHardwareRevision(uint16_t value)
Set the ADC hardware revision for the ADC which recorded this hit.
Definition: DDASHit.h:433
uint32_t getChannelID() const
Retrieve the channel index.
Definition: DDASHit.h:233
uint16_t getHardwareRevision() const
Retrieve the hardware revision.
Definition: DDASHit.h:243
uint32_t getTimeHigh() const
Retrieve most significant 16-bits of raw timestamp.
Definition: DDASHit.h:187
DDASHit()
Default constructor.
Definition: DDASHit.cpp:41
void Reset()
Resets the state of all member data to that of initialization.
Definition: DDASHit.cpp:54
void setCrateID(uint32_t crate)
Set the crate ID.
Definition: DDASHit.h:323
void setExternalTimestamp(uint64_t value)
Set the value of the external timestamp.
Definition: DDASHit.h:472
void setEnergySums(std::vector< uint32_t > eneSums)
Set the energy sum data from an existing set of sums.
Definition: DDASHit.cpp:85
void setChannelID(uint32_t channel)
Set the channel ID.
Definition: DDASHit.h:313
void setEnergy(uint32_t energy)
Set the energy for this hit.
Definition: DDASHit.h:410
void setADCResolution(uint16_t value)
Set the value of the ADC resolution (bit depth) for the ADC which recorded this hit.
Definition: DDASHit.h:427
uint32_t getTimeCFD() const
Retrieve the raw CFD time.
Definition: DDASHit.h:197
void setTimeHigh(uint32_t datum)
Set the higher 16 bits of the 48-bit timestamp.
Definition: DDASHit.cpp:81
uint32_t getChannelLength() const
Retrieve number of 32-bit words that were in original data packet.
Definition: DDASHit.h:213
uint32_t getTraceLength() const
Retrieve trace length.
Definition: DDASHit.h:265
void setQDCSums(std::vector< uint32_t > qdcSums)
Set the QDC sum data from an existing set of sums.
Definition: DDASHit.cpp:96
void setChannelHeaderLength(uint32_t channelHeaderLength)
Set the channel header length.
Definition: DDASHit.h:328
void setSlotID(uint32_t slot)
Set the slot ID.
Definition: DDASHit.h:318
void setTraceLength(uint32_t length)
Set the ADC trace length.
Definition: DDASHit.h:415
double getTime() const
Retrieve computed time.
Definition: DDASHit.h:155
std::vector< uint32_t > & getEnergySums()
Access the energy/baseline sum data.
Definition: DDASHit.h:280
std::vector< uint16_t > & getTrace()
Access the trace data.
Definition: DDASHit.h:270
uint32_t getCFDFailBit() const
Retreive failure bit from CFD data.
Definition: DDASHit.h:260
const std::vector< uint32_t > & getQDCSums() const
Access the QDC data.
Definition: DDASHit.h:295
void setCFDTrigSourceBit(uint32_t bit)
Set the CFD trigger source bit.
Definition: DDASHit.h:376
void setCFDFailBit(uint32_t bit)
Set the CFD fail bit.
Definition: DDASHit.h:387
uint32_t getTimeLow() const
Retrieve least significant 32-bit of raw timestamp.
Definition: DDASHit.h:192