15 #include <Event/Event.h>
16 #include <Event/EventTypes.h>
17 #include <Event/Eventiterator.h>
18 #include <Event/fileEventiterator.h>
27 std::ostream& operator<<(std::ostream& out, const std::list<T>& list)
37 for (
const auto&
value : list)
52 static constexpr
int m_min_req_samples = 5;
105 std::cout <<
"Fetching next Event" << evt->
getEvtSequence() << std::endl;
125 std::cout <<
"SingleMicromegasPoolInput::FillPool - too many packets" << std::endl;
129 for (
int i = 0;
i < npackets;
i++)
143 const int ntagger = packet->lValue(0,
"N_TAGGER");
144 for (
int t = 0;
t < ntagger;
t++)
147 const auto is_lvl1 =
static_cast<uint8_t
>(packet->lValue(
t,
"IS_LEVEL1_TRIGGER"));
151 const auto gtm_bco =
static_cast<uint64_t
>(packet->lValue(
t,
"BCO"));
156 bco_alignment.gtm_bco_list.push_back(gtm_bco);
162 const int nwf = packet->iValue(0,
"NR_WF");
166 std::cout <<
"SingleMicromegasPoolInput::FillPool -"
167 <<
" packet: " << packet_id
169 <<
" n_waveform: " << nwf
172 std::cout <<
"SingleMicromegasPoolInput::FillPool -"
173 <<
" packet: " << packet_id
179 using fee_pair_t = std::pair<unsigned int, unsigned int>;
180 std::set<fee_pair_t> orphans;
182 for (
int wf = 0; wf < nwf; wf++)
185 const int fee_id = packet->iValue(wf,
"FEE");
188 const auto checksum_error = packet->iValue(wf,
"CHECKSUMERROR");
195 const uint16_t samples = packet->iValue(wf,
"SAMPLES");
196 if (samples < m_min_req_samples)
202 const unsigned int fee_bco = packet->iValue(wf,
"BCO");
205 uint64_t gtm_bco = 0;
207 if (bco_alignment.fee_bco == fee_bco)
210 gtm_bco = bco_alignment.gtm_bco;
212 else if (!bco_alignment.gtm_bco_list.empty())
215 gtm_bco = bco_alignment.gtm_bco_list.front();
219 std::cout <<
"SingleMicromegasPoolInput::FillPool -"
220 <<
" fee_id: " << fee_id
221 <<
" fee_bco: 0x" << std::hex << fee_bco
222 <<
" gtm_bco: 0x" << gtm_bco
228 bco_alignment.fee_bco = fee_bco;
229 bco_alignment.gtm_bco = gtm_bco;
232 bco_alignment.gtm_bco_list.pop_front();
236 if (
Verbosity() && orphans.insert(std::make_pair(fee_id, fee_bco)).second)
238 std::cout <<
"SingleMicromegasPoolInput::FillPool -"
239 <<
" fee_id: " << fee_id
240 <<
" fee_bco: 0x" << std::hex << fee_bco << std::dec
250 auto newhit = std::make_unique<MicromegasRawHitv1>();
251 newhit->set_bco(fee_bco);
252 newhit->set_gtm_bco(gtm_bco);
255 newhit->set_packetid(packet_id);
256 newhit->set_fee(fee_id);
257 newhit->set_channel(packet->iValue(wf,
"CHANNEL"));
258 newhit->set_sampaaddress(packet->iValue(wf,
"SAMPAADDRESS"));
259 newhit->set_sampachannel(packet->iValue(wf,
"CHANNEL"));
262 newhit->set_samples(samples);
265 for (uint16_t is = 0; is < samples; ++is)
267 newhit->set_adc(is, packet->iValue(wf, is));
274 std::cout <<
"evtno: " << EventSequence
276 <<
", num waveforms: " << nwf
277 <<
", bco: 0x" << std::hex << gtm_bco << std::dec
278 <<
", FEE: " << fee_id << std::endl;
293 bco_alignment.gtm_bco_list.clear();
304 if (what ==
"ALL" || what ==
"FEE")
308 std::cout <<
"Beam clock 0x" << std::hex << bcliter.first << std::dec << std::endl;
309 for (
auto feeiter : bcliter.second)
311 std::cout <<
"FEM: " << feeiter << std::endl;
316 if (what ==
"ALL" || what ==
"FEEBCLK")
320 std::cout <<
"FEE" << bcliter.first <<
" bclk: 0x"
321 << std::hex << bcliter.second << std::dec << std::endl;
325 if (what ==
"ALL" || what ==
"STORAGE")
329 std::cout <<
"Beam clock 0x" << std::hex << bcliter.first << std::dec << std::endl;
330 for (
auto feeiter : bcliter.second)
333 <<
"fee: " << feeiter->get_fee()
334 <<
" at " << std::hex << feeiter << std::dec
340 if (what ==
"ALL" || what ==
"STACK")
344 std::cout <<
"stacked bclk: 0x" << std::hex << iter << std::dec << std::endl;
352 std::vector<uint64_t> toclearbclk;
355 if (iter.first <= bclk)
357 for (
auto pktiter : iter.second)
362 toclearbclk.push_back(iter.first);
370 for (
auto iter : toclearbclk)
374 m_MicromegasRawHitMap.erase(iter);
401 if (bcliter.second <= lowest_bclk)
426 dstNode->addNode(detNode);
429 auto container = findNode::getClass<MicromegasRawHitContainer>(detNode,
"MICROMEGASRAWHIT");
434 detNode->addNode(newNode);