CbmRoot
CbmTrdRawMessageSpadic.cxx
Go to the documentation of this file.
2 
3 #include <FairLogger.h> // for LOG
4 
5 #include <algorithm> // for max_element
6 #include <stdexcept> // for range_error
7 
8 // ------- Default Constructor ----------------
10  : fChannelID()
11  , fElinkID()
12  , fCrobId()
13  , fCriId()
14  , fHitType()
15  , fNrSamples()
16  , fMultiHit()
17  , fFullTime()
18  , fSamples() {}
19 
20 // ------- Constructor ----------------
22  std::uint8_t channelId,
23  std::uint8_t elinkId,
24  std::uint8_t crobId,
25  std::uint16_t criId,
26  std::uint8_t hitType,
27  std::uint8_t nrSamples,
28  bool multiHit,
29  std::uint64_t fullTime,
30  std::vector<std::int16_t> samples)
31  : fChannelID {channelId}
32  , fElinkID {elinkId}
33  , fCrobId(crobId)
34  , fCriId {criId}
35  , fHitType {hitType}
36  , fNrSamples {nrSamples}
37  , fMultiHit {multiHit}
38  , fFullTime {fullTime}
39  , fSamples(samples) {
40  // throw an exception if samples has more than 32 elements.
41  if (fSamples.size() > 32) {
42  LOG(error) << "CbmTrdRawMessageSpadic: too many samples in message!";
43  throw std::range_error(
44  "CbmTrdRawMessageSpadic: too many samples in message!");
45  }
46 }
47 
48 // ------- copy Constructor ----------------
50  const CbmTrdRawMessageSpadic& old)
51  : fChannelID {old.fChannelID}
52  , fElinkID {old.fElinkID}
53  , fCrobId(old.fCrobId)
54  , fCriId {old.fCriId}
55  , fHitType {old.fHitType}
56  , fNrSamples {old.fNrSamples}
57  , fMultiHit {old.fMultiHit}
58  , fFullTime {old.fFullTime}
59  , fSamples(old.fSamples) {}
60 
61 // ------- Destructor ----------------
63 
65  int16_t maxADC = *std::max_element(fSamples.begin(), fSamples.end());
66 
67  return maxADC;
68 }
69 
70 void CbmTrdRawMessageSpadic::SetSample(std::int16_t value, std::uint8_t pos) {
71  if (pos > 31 || value < -256 || value > 256 || pos >= fNrSamples) {
72  LOG(error) << "CbmTrdRawMessageSpadic::SetSample() Out of range!";
73  return;
74  }
75  if ((std::uint8_t)(pos + 1) > fSamples.size()) { fSamples.resize(pos + 1); }
76  fSamples[pos] = value;
77 
78  return;
79 }
80 
CbmTrdRawMessageSpadic::fNrSamples
std::uint8_t fNrSamples
Definition: CbmTrdRawMessageSpadic.h:77
CbmTrdRawMessageSpadic::SetSample
void SetSample(std::int16_t value, std::uint8_t pos)
Definition: CbmTrdRawMessageSpadic.cxx:70
CbmTrdRawMessageSpadic::fSamples
std::vector< std::int16_t > fSamples
Definition: CbmTrdRawMessageSpadic.h:81
CbmTrdRawMessageSpadic
Base class for storing raw information which comes from the Spadic v2.2 trough flib or from a tsa fil...
Definition: CbmTrdRawMessageSpadic.h:68
CbmTrdRawMessageSpadic::GetMaxAdc
int16_t GetMaxAdc()
Definition: CbmTrdRawMessageSpadic.cxx:64
CbmTrdRawMessageSpadic::CbmTrdRawMessageSpadic
CbmTrdRawMessageSpadic()
Definition: CbmTrdRawMessageSpadic.cxx:9
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmTrdRawMessageSpadic::~CbmTrdRawMessageSpadic
virtual ~CbmTrdRawMessageSpadic()
Definition: CbmTrdRawMessageSpadic.cxx:62
CbmTrdRawMessageSpadic.h
CbmTrdRawMessageSpadic::fChannelID
std::uint8_t fChannelID
Definition: CbmTrdRawMessageSpadic.h:72