pdspctb.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // An offline-friendly packaging of the Central Trigger Board (CTB)'s data for ProtoDUNE-SP
4 // Tom Junk, August 10, 2018
5 //
6 ////////////////////////////////////////////////////////////////////////
7 
8 #ifndef pdspctb_H
9 #define pdspctb_H
10 
11 #include "RtypesCore.h"
12 #include <stdint.h>
13 
14 namespace raw {
15 
16  namespace ctb {
17 
18  struct Trigger {
19  uint32_t word_type;
20  ULong64_t trigger_word;
21  ULong64_t timestamp;
22  };
23 
24  struct ChStatus {
25  uint32_t word_type;
26  uint32_t pds;
27  uint32_t crt;
28  uint32_t beam_hi;
29  uint32_t beam_lo;
30  ULong64_t timestamp;
31  };
32 
33  struct Feedback {
34  uint32_t word_type;
35  uint32_t padding;
36  uint32_t source;
37  uint32_t code;
38  ULong64_t timestamp;
39  };
40 
41  struct Misc {
42  uint32_t word_type;
43  ULong64_t payload;
44  ULong64_t timestamp;
45  };
46 
47  struct WordIndex {
48  uint32_t word_type;
49  uint32_t index;
50  };
51 
52  class pdspctb
53  {
54 
55  public:
56 
57  pdspctb() {}; // Constructor of an emtpy data product
58 
59  // constructor with all of the vectors set
60  pdspctb(std::vector<raw::ctb::Trigger> &trigs,
61  std::vector<raw::ctb::ChStatus> &chstats,
62  std::vector<raw::ctb::Feedback> &fbs,
63  std::vector<raw::ctb::Misc> &m,
64  std::vector<raw::ctb::WordIndex> &wordindexes) :
65  fTriggers(trigs), fChStatuses(chstats), fFeedbacks(fbs), fMiscs(m), fIndexes(wordindexes) {};
66 
67 
68  const std::vector<raw::ctb::Trigger>& GetTriggers() const;
69  const std::vector<raw::ctb::ChStatus>& GetChStatuses() const;
70  const std::vector<raw::ctb::Feedback>& GetFeedbacks() const;
71  const std::vector<raw::ctb::Misc>& GetMiscs() const;
72  const std::vector<raw::ctb::WordIndex>& GetIndexes() const;
73 
74  const std::vector<raw::ctb::Trigger> GetHLTriggers() const;
75  const std::vector<raw::ctb::Trigger> GetLLTriggers() const;
76  const std::vector<raw::ctb::ChStatus> GetChStatusAfterHLTs() const;
77 
78  size_t GetNTriggers() const;
79  size_t GetNChStatuses() const;
80  size_t GetNFeedbacks() const;
81  size_t GetNMiscs() const;
82  size_t GetNIndexes() const;
83 
84  const raw::ctb::Trigger& GetTrigger(size_t i) const;
85  const raw::ctb::ChStatus& GetChStatuse(size_t i) const;
86  const raw::ctb::Feedback& GetFeedback(size_t i) const;
87  const raw::ctb::Misc& GetMisc(size_t i) const;
88  const raw::ctb::WordIndex& GetIndex(size_t i) const;
89 
90  private:
91 
92  std::vector<raw::ctb::Trigger> fTriggers;
93  std::vector<raw::ctb::ChStatus> fChStatuses;
94  std::vector<raw::ctb::Feedback> fFeedbacks;
95  std::vector<raw::ctb::Misc> fMiscs;
96  std::vector<raw::ctb::WordIndex> fIndexes;
97 
98  };
99 
100 
101  } // namespace ctb
102 } // namespace raw
103 
104 // accessors
105 
106 const std::vector<raw::ctb::Trigger>& raw::ctb::pdspctb::GetTriggers() const { return fTriggers; }
107 const std::vector<raw::ctb::ChStatus>& raw::ctb::pdspctb::GetChStatuses() const { return fChStatuses; }
108 const std::vector<raw::ctb::Feedback>& raw::ctb::pdspctb::GetFeedbacks() const { return fFeedbacks; }
109 const std::vector<raw::ctb::Misc>& raw::ctb::pdspctb::GetMiscs() const { return fMiscs; }
110 const std::vector<raw::ctb::WordIndex>& raw::ctb::pdspctb::GetIndexes() const { return fIndexes; }
111 
112 const std::vector<raw::ctb::Trigger> raw::ctb::pdspctb::GetHLTriggers() const
113 {
114  std::vector<raw::ctb::Trigger> HLTriggers;
115  for (size_t i=0; i<fTriggers.size(); ++i)
116  {
117  if (fTriggers.at(i).word_type == 2)
118  {
119  HLTriggers.push_back(fTriggers.at(i));
120  }
121  }
122  return HLTriggers;
123 }
124 
125 // for each HLT, find the next entry
126 
127 const std::vector<raw::ctb::ChStatus> raw::ctb::pdspctb::GetChStatusAfterHLTs() const
128 {
129  std::vector<raw::ctb::ChStatus> chs;
130  raw::ctb::ChStatus emptychstat;
131  emptychstat.word_type = 0;
132  emptychstat.pds = 0;
133  emptychstat.crt = 0;
134  emptychstat.beam_hi = 0;
135  emptychstat.beam_lo = 0;
136  emptychstat.timestamp = 0;
137 
138  for (size_t i=0; i<fTriggers.size(); ++i)
139  {
140  if (fTriggers.at(i).word_type == 2)
141  {
142  // find this HL trigger word in the indexes vector. Assume the next entry is a chstatus
143 
144  for (size_t j=0; j<fIndexes.size(); ++j)
145  {
146  if (fIndexes.at(j).word_type == 2 && fIndexes.at(j).index == i)
147  {
148  size_t kstatindex = j;
149  if (kstatindex > 0)
150  {
151  kstatindex --; // it's the word before the HLT that has the chstat
152  if (fIndexes.at(kstatindex).word_type == 3)
153  {
154  size_t kstat = fIndexes.at(kstatindex).index;
155 
156  if (kstat < fChStatuses.size())
157  {
158  chs.push_back(fChStatuses.at(kstat));
159  }
160  else
161  {
162  chs.push_back(emptychstat);
163  }
164  }
165  else
166  {
167  chs.push_back(emptychstat);
168  }
169  }
170  else
171  {
172  chs.push_back(emptychstat);
173  }
174  }
175  }
176  }
177  }
178  return chs;
179 }
180 
181 const std::vector<raw::ctb::Trigger> raw::ctb::pdspctb::GetLLTriggers() const
182 {
183  std::vector<raw::ctb::Trigger> LLTriggers;
184  for (size_t i=0; i<fTriggers.size(); ++i)
185  {
186  if (fTriggers.at(i).word_type == 1)
187  {
188  LLTriggers.push_back(fTriggers.at(i));
189  }
190  }
191  return LLTriggers;
192 }
193 
194 size_t raw::ctb::pdspctb::GetNTriggers() const { return fTriggers.size(); }
195 size_t raw::ctb::pdspctb::GetNChStatuses() const { return fChStatuses.size(); }
196 size_t raw::ctb::pdspctb::GetNFeedbacks() const { return fFeedbacks.size(); }
197 size_t raw::ctb::pdspctb::GetNMiscs() const { return fMiscs.size(); }
198 size_t raw::ctb::pdspctb::GetNIndexes() const { return fIndexes.size(); }
199 
200 const raw::ctb::Trigger& raw::ctb::pdspctb::GetTrigger(size_t i) const { return fTriggers.at(i); }
201 const raw::ctb::ChStatus& raw::ctb::pdspctb::GetChStatuse(size_t i) const { return fChStatuses.at(i); }
202 const raw::ctb::Feedback& raw::ctb::pdspctb::GetFeedback(size_t i) const { return fFeedbacks.at(i); }
203 const raw::ctb::Misc& raw::ctb::pdspctb::GetMisc(size_t i) const { return fMiscs.at(i); }
204 const raw::ctb::WordIndex& raw::ctb::pdspctb::GetIndex(size_t i) const { return fIndexes.at(i); }
205 
206 
207 #endif // pdspctb_H
size_t GetNFeedbacks() const
Definition: pdspctb.h:196
const std::vector< raw::ctb::Trigger > & GetTriggers() const
Definition: pdspctb.h:106
ULong64_t trigger_word
Definition: pdspctb.h:20
std::vector< raw::ctb::ChStatus > fChStatuses
Definition: pdspctb.h:93
uint32_t index
Definition: pdspctb.h:49
const std::vector< raw::ctb::ChStatus > GetChStatusAfterHLTs() const
Definition: pdspctb.h:127
const raw::ctb::Misc & GetMisc(size_t i) const
Definition: pdspctb.h:203
std::vector< raw::ctb::Trigger > fTriggers
Definition: pdspctb.h:92
pdspctb(std::vector< raw::ctb::Trigger > &trigs, std::vector< raw::ctb::ChStatus > &chstats, std::vector< raw::ctb::Feedback > &fbs, std::vector< raw::ctb::Misc > &m, std::vector< raw::ctb::WordIndex > &wordindexes)
Definition: pdspctb.h:60
ULong64_t payload
Definition: pdspctb.h:43
const raw::ctb::ChStatus & GetChStatuse(size_t i) const
Definition: pdspctb.h:201
uint32_t crt
Definition: pdspctb.h:27
const std::vector< raw::ctb::WordIndex > & GetIndexes() const
Definition: pdspctb.h:110
Raw data description.
ULong64_t timestamp
Definition: pdspctb.h:38
const std::vector< raw::ctb::Trigger > GetLLTriggers() const
Definition: pdspctb.h:181
size_t GetNChStatuses() const
Definition: pdspctb.h:195
uint32_t padding
Definition: pdspctb.h:35
const std::vector< raw::ctb::Feedback > & GetFeedbacks() const
Definition: pdspctb.h:108
const raw::ctb::Feedback & GetFeedback(size_t i) const
Definition: pdspctb.h:202
uint32_t code
Definition: pdspctb.h:37
std::vector< raw::ctb::WordIndex > fIndexes
Definition: pdspctb.h:96
const std::vector< raw::ctb::ChStatus > & GetChStatuses() const
Definition: pdspctb.h:107
const std::vector< raw::ctb::Misc > & GetMiscs() const
Definition: pdspctb.h:109
ULong64_t timestamp
Definition: pdspctb.h:21
std::vector< raw::ctb::Misc > fMiscs
Definition: pdspctb.h:95
uint32_t source
Definition: pdspctb.h:36
uint32_t word_type
Definition: pdspctb.h:19
uint32_t word_type
Definition: pdspctb.h:48
size_t GetNIndexes() const
Definition: pdspctb.h:198
uint32_t beam_lo
Definition: pdspctb.h:29
uint32_t beam_hi
Definition: pdspctb.h:28
size_t GetNMiscs() const
Definition: pdspctb.h:197
uint32_t pds
Definition: pdspctb.h:26
const raw::ctb::WordIndex & GetIndex(size_t i) const
Definition: pdspctb.h:204
size_t GetNTriggers() const
Definition: pdspctb.h:194
uint32_t word_type
Definition: pdspctb.h:25
const raw::ctb::Trigger & GetTrigger(size_t i) const
Definition: pdspctb.h:200
uint32_t word_type
Definition: pdspctb.h:34
ULong64_t timestamp
Definition: pdspctb.h:30
ULong64_t timestamp
Definition: pdspctb.h:44
const std::vector< raw::ctb::Trigger > GetHLTriggers() const
Definition: pdspctb.h:112
uint32_t word_type
Definition: pdspctb.h:42
std::vector< raw::ctb::Feedback > fFeedbacks
Definition: pdspctb.h:94