8 #include "art/Framework/Core/EDProducer.h"
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Principal/Event.h"
11 #include "art/Framework/Principal/Handle.h"
12 #include "art/Framework/Principal/Run.h"
13 #include "art/Framework/Principal/SubRun.h"
14 #include "canvas/Utilities/InputTag.h"
15 #include "canvas/Persistency/Common/FindMany.h"
16 #include "canvas/Persistency/Common/FindOne.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
22 #include "artdaq-core/Data/Fragment.hh"
23 #include "sbndaq-artdaq-core/Overlays/ICARUS/PhysCrateFragment.hh"
24 #include "sbndaq-artdaq-core/Overlays/Common/CAENV1730Fragment.hh"
43 void produce(art::Event &
e)
override;
68 Config(fhicl::ParameterSet
const & p);
72 void process_fragment(art::Event &event,
const artdaq::Fragment &frag, std::unique_ptr<std::vector<raw::RawDigit>> &product_collectionf);
94 art::EDProducer{param},
95 _tag(param.get<art::InputTag>(
"FragmentsLabel",
"daq:CAENV1730")),
102 produces<std::vector<raw::OpDetWaveform>>();
112 double wait_time = param.get<
double>(
"wait_time", -1 );
114 wait_usec = (int) (wait_time / 1000000.);
120 n_mode_skip = param.get<
unsigned>(
"n_mode_skip", 1);
125 timesize = param.get<
unsigned>(
"timesize", 1);
134 min_slot_no = param.get<
unsigned>(
"min_slot_no", 0);
146 std::unique_ptr<std::vector<raw::OpDetWaveform>> product_collection(
new std::vector<raw::OpDetWaveform>());
151 art::Handle< std::vector<artdaq::Fragment> > rawFragHandle;
152 event.getByLabel(
_tag, rawFragHandle);
154 if (rawFragHandle.isValid()) {
156 std::cout <<
"######################################################################\n";
157 std::cout <<
"Run " <<
event.run() <<
", subrun " <<
event.subRun() << std::endl;
159 for (
size_t idx = 0; idx < rawFragHandle->size(); ++idx)
162 const auto& frag((*rawFragHandle)[idx]);
163 sbndaq::CAENV1730Fragment bb(frag);
164 auto const*
md = bb.Metadata();
165 sbndaq::CAENV1730Event
const* event_ptr = bb.Event();
166 sbndaq::CAENV1730EventHeader header = event_ptr->Header;
168 std::cout <<
"\tFragment ID: " << frag.fragmentID() <<
", type: " << frag.typeString() <<
", type: " << frag.type() <<
", boardID: " << header.boardID <<
", msk lo: " << header.channelMask_lo <<
", hi: " << header.channelMask_hi << std::endl;
169 std::cout <<
"\tFrom header, event counter is " << header.eventCounter <<
"\n";
170 std::cout <<
"\tFrom header, triggerTimeTag is " << header.triggerTimeTag <<
"\n";
171 std::vector< std::vector<uint16_t> > fWvfmsVec;
172 size_t nChannels =
md->nChannels;
173 std::cout <<
"\tFrom header , no of channel is " << nChannels <<
"\n";
175 uint32_t ev_size_quad_bytes = header.eventSize;
177 uint32_t evt_header_size_quad_bytes =
sizeof(sbndaq::CAENV1730EventHeader)/
sizeof(uint32_t);
178 uint32_t data_size_double_bytes = 2*(ev_size_quad_bytes - evt_header_size_quad_bytes);
179 uint32_t wfm_length = data_size_double_bytes/nChannels;
184 const uint16_t* data_begin =
reinterpret_cast<const uint16_t*
>(frag.dataBeginBytes()
185 +
sizeof(sbndaq::CAENV1730EventHeader));
187 const uint16_t* value_ptr = data_begin;
188 size_t ch_offset = 0;
192 for (
size_t i_ch=0; i_ch<nChannels; ++i_ch)
195 ch_offset = i_ch * wfm_length;
198 my_wf.resize(wfm_length);
201 for(
size_t i_t=0; i_t<wfm_length; ++i_t)
204 value_ptr = data_begin + ch_offset + i_t;
206 value = *(value_ptr);
213 product_collection->push_back(my_wf);
218 event.put(std::move(product_collection));
236 icarus::PhysCrateFragment fragment(frag);
237 std::cout <<
" n boards " << fragment.nBoards() << std::endl;
240 for(
size_t i_b=0; i_b < fragment.nBoards(); i_b++)
244 for(
size_t i_ch=0; i_ch < fragment.nChannelsPerBoard(); ++i_ch)
250 for(
size_t i_t=0; i_t < fragment.nSamplesPerChannel(); ++i_t)
252 wvfm[i_t] = fragment.adc_val(i_b,i_ch,i_t);
256 product_collection->emplace_back(channel_num,fragment.nSamplesPerChannel(),wvfm);
262 std::cout <<
"Total number of channels added is " << product_collection->size() << std::endl;
void process_fragment(art::Event &event, const artdaq::Fragment &frag, std::unique_ptr< std::vector< raw::RawDigit >> &product_collectionf)
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition of basic raw digits.
microsecond microseconds
Alias for common language habits.
Config(fhicl::ParameterSet const &p)
second seconds
Alias for common language habits.
unsigned channel_per_slot
DaqDecoderIcarusPMTold(fhicl::ParameterSet const &p)
void produce(art::Event &e) override
unsigned int ChannelID_t
Type representing the ID of a readout channel.
BEGIN_PROLOG could also be cout