PDSPCTBRawDecoder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PDSPCTBRawDecoder
3 // Plugin Type: producer (art v2_11_03)
4 // File: PDSPCTBRawDecoder_module.cc
5 //
6 // Generated at Mon Aug 13 16:42:23 2018 by Thomas Junk using cetskelgen
7 // from cetlib version v3_03_01.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
20 #include <memory>
21 
22 // artdaq and dune-raw-data includes
23 
25 #include "artdaq-core/Data/ContainerFragment.hh"
27 
28 // dunetpc includes
29 
31 
32 class PDSPCTBRawDecoder;
33 
34 
36 public:
37  explicit PDSPCTBRawDecoder(fhicl::ParameterSet const & p);
38  // The compiler-generated destructor is fine for non-base
39  // classes without bare pointers or other resource use.
40 
41  // Plugins should not be copied or assigned.
42  PDSPCTBRawDecoder(PDSPCTBRawDecoder const &) = delete;
46 
47  // Required functions.
48  void produce(art::Event & e) override;
49 
50 private:
51 
52  // Declare member data here.
53 
58 
59  void _process_CTB_AUX(const artdaq::Fragment& frag);
60 
61  std::vector<raw::ctb::Trigger> fTrigs;
62  std::vector<raw::ctb::ChStatus> fChStats;
63  std::vector<raw::ctb::Feedback> fFeedbacks;
64  std::vector<raw::ctb::Misc> fMiscs;
65  std::vector<raw::ctb::WordIndex> fWordIndexes;
66 
67 };
68 
69 
71  : EDProducer{p}
72 // Initialize member data here.
73 {
74  fInputLabel = p.get<std::string>("InputLabel");
75  fInputContainerInstance = p.get<std::string>("InputContainerInstance");
76  fInputNonContainerInstance = p.get<std::string>("InputNonContainerInstance");
77  fOutputLabel = p.get<std::string>("OutputLabel");
78 
79  produces<std::vector<raw::ctb::pdspctb> >(fOutputLabel);
80 }
81 
83 {
84 
85  fTrigs.clear();
86  fChStats.clear();
87  fFeedbacks.clear();
88  fMiscs.clear();
89  fWordIndexes.clear();
90 
91  // look first for container fragments and then non-container fragments
92 
93  std::vector<raw::ctb::pdspctb> pdspctbs;
94 
96  auto cont_frags = evt.getHandle<artdaq::Fragments>(itag1);
97  if (cont_frags)
98  {
99  for (auto const& cont : *cont_frags)
100  {
101  artdaq::ContainerFragment cont_frag(cont);
102  for (size_t ii = 0; ii < cont_frag.block_count(); ++ii)
103  {
104  _process_CTB_AUX(*cont_frag[ii]);
105  }
106  }
107  }
108 
110  auto frags = evt.getHandle<artdaq::Fragments>(itag2);
111  if (frags)
112  {
113  for(auto const& frag: *frags)
114  {
115  _process_CTB_AUX(frag);
116  }
117  }
118 
120  pdspctbs.push_back(ctbdp); // just one for now
121  evt.put(std::make_unique<std::vector<raw::ctb::pdspctb>>(std::move(pdspctbs)),fOutputLabel);
122 
123 }
124 
125 void PDSPCTBRawDecoder::_process_CTB_AUX(const artdaq::Fragment& frag)
126 {
127  dune::CTBFragment ctbfrag(frag);
128 
129  // use the same logic in dune-raw-data/Overlays/CTBFragment.cc:operator<<
130 
131  for (size_t iword = 0; iword < ctbfrag.NWords(); ++iword)
132  {
133  size_t ix=0;
134  uint32_t wt=0;
135  if (ctbfrag.Trigger(iword))
136  {
137  raw::ctb::Trigger tstruct;
138  tstruct.word_type = ctbfrag.Trigger(iword)->word_type;
139  wt = tstruct.word_type;
140  tstruct.trigger_word = ctbfrag.Trigger(iword)->trigger_word;
141  tstruct.timestamp = ctbfrag.Trigger(iword)->timestamp;
142  ix = fTrigs.size();
143  fTrigs.push_back(tstruct);
144  }
145  else if (ctbfrag.ChStatus(iword))
146  {
147  raw::ctb::ChStatus cstruct;
148  cstruct.word_type = ctbfrag.ChStatus(iword)->word_type;
149  wt = cstruct.word_type;
150  cstruct.pds = ctbfrag.ChStatus(iword)->pds;
151  cstruct.crt = ctbfrag.ChStatus(iword)->crt;
152  cstruct.beam_hi = ctbfrag.ChStatus(iword)->beam_hi;
153  cstruct.beam_lo = ctbfrag.ChStatus(iword)->beam_lo;
154  cstruct.timestamp = ctbfrag.ChStatus(iword)->timestamp;
155  ix = fChStats.size();
156  fChStats.push_back(cstruct);
157  }
158  else if (ctbfrag.Feedback(iword))
159  {
160  raw::ctb::Feedback fstruct;
161  fstruct.word_type = ctbfrag.Feedback(iword)->word_type;
162  wt = fstruct.word_type;
163  fstruct.padding = ctbfrag.Feedback(iword)->padding;
164  fstruct.source = ctbfrag.Feedback(iword)->source;
165  fstruct.code = ctbfrag.Feedback(iword)->code;
166  fstruct.timestamp = ctbfrag.Feedback(iword)->timestamp;
167  ix = fFeedbacks.size();
168  fFeedbacks.push_back(fstruct);
169  }
170  else
171  {
172  raw::ctb::Misc mstruct;
173  mstruct.word_type = ctbfrag.Word(iword)->word_type;
174  wt = mstruct.word_type;
175  mstruct.payload = ctbfrag.Word(iword)->payload;
176  mstruct.timestamp = ctbfrag.Word(iword)->timestamp;
177  ix = fMiscs.size();
178  fMiscs.push_back(mstruct);
179  }
180 
181  raw::ctb::WordIndex wstruct;
182  wstruct.word_type = wt;
183  wstruct.index = ix;
184  fWordIndexes.push_back(wstruct);
185 
186  }
187 }
188 
189 
const ptb::content::word::ch_status_t * ChStatus(unsigned int i) const
Definition: CTBFragment.cc:79
ULong64_t trigger_word
Definition: pdspctb.h:20
uint32_t index
Definition: pdspctb.h:49
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
std::string fInputNonContainerInstance
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
ULong64_t payload
Definition: pdspctb.h:43
uint32_t crt
Definition: pdspctb.h:27
const ptb::content::word::word_t * Word(unsigned int i) const
Definition: CTBFragment.cc:59
ULong64_t timestamp
Definition: pdspctb.h:38
void produce(art::Event &e) override
std::vector< raw::ctb::Feedback > fFeedbacks
PDSPCTBRawDecoder & operator=(PDSPCTBRawDecoder const &)=delete
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
uint32_t padding
Definition: pdspctb.h:35
def move(depos, offset)
Definition: depos.py:107
uint32_t code
Definition: pdspctb.h:37
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::vector< raw::ctb::Misc > fMiscs
ULong64_t timestamp
Definition: pdspctb.h:21
const ptb::content::word::trigger_t * Trigger(unsigned int i) const
Definition: CTBFragment.cc:101
uint32_t source
Definition: pdspctb.h:36
uint32_t word_type
Definition: pdspctb.h:19
uint32_t word_type
Definition: pdspctb.h:48
uint32_t beam_lo
Definition: pdspctb.h:29
uint32_t beam_hi
Definition: pdspctb.h:28
std::vector< raw::ctb::Trigger > fTrigs
std::vector< raw::ctb::ChStatus > fChStats
uint32_t pds
Definition: pdspctb.h:26
const ptb::content::word::feedback_t * Feedback(unsigned int i) const
Definition: CTBFragment.cc:68
void _process_CTB_AUX(const artdaq::Fragment &frag)
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< raw::ctb::WordIndex > fWordIndexes
uint32_t word_type
Definition: pdspctb.h:25
uint32_t word_type
Definition: pdspctb.h:34
ULong64_t timestamp
Definition: pdspctb.h:30
unsigned int NWords() const noexcept
Definition: CTBFragment.hh:47
ULong64_t timestamp
Definition: pdspctb.h:44
uint32_t word_type
Definition: pdspctb.h:42
std::vector< Fragment > Fragments
Definition: HDF5Utils.h:57
PDSPCTBRawDecoder(fhicl::ParameterSet const &p)