BmnRoot 26.10.0-19-g6979a6c6
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnTrigWaveDigit.h
Go to the documentation of this file.
1#ifndef BMNTRIGWAVEDIGIT_H
2#define BMNTRIGWAVEDIGIT_H
3
4#include <iostream>
5#include <vector>
6
7using std::vector;
8
9#include <TObject.h>
10
11/**
12 * class for TQDC data including waveform
13 * can be initialized both from an std::vector and raw pointer to an array
14 */
16{
17 public:
19 BmnTrigWaveDigit(uint16_t iMod,
20 vector<int16_t>&& iValue,
21 Double_t trigTimestamp,
22 Double_t adcTimestamp,
23 Double_t time = 0);
24
25 BmnTrigWaveDigit(uint16_t iMod,
26 int16_t* iValue,
27 uint32_t nVals,
28 Double_t trigTimestamp,
29 Double_t adcTimestamp,
30 Double_t time = 0);
31
32 uint16_t GetMod() const { return fMod; }
33
34 size_t GetNSamples() const
35 {
36 if (fValueI)
37 return fNsmpl; // backward compatibility
38 else
39 return fValue.size();
40 }
41
42 int32_t GetIntegral(size_t start = 0, size_t stop = SIZE_MAX) const
43 {
44 stop = std::min(stop, fValue.size());
45 start = std::min(start, stop);
46 int32_t spectra = 0;
47 for (size_t i = start; i < stop; ++i)
48 spectra += fValue[i];
49 return spectra;
50 }
51
52 int16_t GetPeak(size_t start = 0, size_t stop = SIZE_MAX) const
53 {
54 stop = std::min(stop, fValue.size());
55 start = std::min(start, stop);
56 int16_t peak = INT16_MIN;
57 for (size_t i = start; i < stop; ++i)
58 if (fValue[i] > peak)
59 peak = fValue[i];
60 return peak;
61 }
62
63 // int16_t *GetShortValue() const {
64 // return fValueI;
65 // }
66
67 vector<int16_t>& GetValue() { return fValue; }
68
70
72
73 Double_t GetTime() const { return fTime; }
74
75 vector<Double_t>& TdcVector() { return fTdcTimes; }
76
77 virtual ~BmnTrigWaveDigit();
78
79 protected:
80 uint16_t fMod;
81 /**
82 * ROOT schema evolution does not work as stated in their manual
83 * So we have to hold old fields in order to transition from the old version.
84 * https://root.cern/manual/io/ even says it works automatically,
85 * actually it does not work neither automatically nor even by linkdef
86 * pragma read function if the fields are not present in the current version.
87 * And the custom Streamer method is impossible to make being called during
88 * object deserialization from a tree
89 */
90 uint32_t fNsmpl;
91 int16_t* fValueI; //[fNsmpl]
92 vector<int16_t> fValue;
96 vector<Double_t> fTdcTimes;
97
99};
100
101#endif /* BMNTRIGWAVEDIGIT_H */
int i
Definition P4_F32vec4.h:22
double Double_t
#define ClassDef(name, id)
Double_t GetTrigTimestamp() const
Double_t GetTime() const
uint32_t fNsmpl
ROOT schema evolution does not work as stated in their manual So we have to hold old fields in order ...
vector< int16_t > & GetValue()
BmnTrigWaveDigit(uint16_t iMod, vector< int16_t > &&iValue, Double_t trigTimestamp, Double_t adcTimestamp, Double_t time=0)
size_t GetNSamples() const
int32_t GetIntegral(size_t start=0, size_t stop=SIZE_MAX) const
vector< Double_t > fTdcTimes
Double_t GetAdcTimestamp() const
vector< int16_t > fValue
int16_t GetPeak(size_t start=0, size_t stop=SIZE_MAX) const
uint16_t GetMod() const
BmnTrigWaveDigit(uint16_t iMod, int16_t *iValue, uint32_t nVals, Double_t trigTimestamp, Double_t adcTimestamp, Double_t time=0)
vector< Double_t > & TdcVector()