19 #include <Event/A_Event.h>
20 #include <Event/Event.h>
21 #include <Event/oEvent.h>
22 #include <Event/packet.h>
33 , m_PrdfNodeName(prdfnodename)
61 for (
auto const &pktiter : pktinfoiter.second.PacketVector)
81 bool event_ok =
false;
97 std::cout <<
"we are done" << std::endl;
102 int eventnumber = pktinfoiter->first;
118 std::cout <<
"Houston we have a problem with event " << eventnumber << std::endl;
119 std::cout <<
"name " << veciter.second->Name() <<
", diffclk: 0x" << std::hex
120 << diffclock <<
", my bclk: 0x" << veciter.first
121 <<
", ref clk: 0x" << refclock << std::dec << std::endl;
132 for (
auto &pktiter : pktinfoiter->second.PacketVector)
144 for (
auto &pktiter : pktinfoiter->second.PacketVector)
236 m_PrdfInputVector.clear();
243 if (what ==
"ALL" || what ==
"DROPPED")
245 std::cout <<
"-----------------------------" << std::endl;
246 std::cout <<
"dropped packets:" << std::endl;
249 std::cout <<
"Packet " << iter.first <<
" was dropped " << iter.second <<
" times" << std::endl;
346 std::cout <<
PHWHERE <<
Name() <<
" No MasterSync object, cannot perform synchronization" << std::endl;
347 std::cout <<
"Most likely your first file does not contain a SyncObject and the file" << std::endl;
348 std::cout <<
"opened by the Fun4AllDstInputManager with Name " <<
Name() <<
" has one" << std::endl;
349 std::cout <<
"Change your macro and use the file opened by this input manager as first input" << std::endl;
350 std::cout <<
"and you will be okay. Fun4All will not process the current configuration" << std::endl
357 std::cout <<
"big problem" << std::endl;
365 if (what ==
"PRDFNODENAME")
398 std::cout <<
"Adding packet " << p->
getIdentifier() <<
" to event no " << evtno << std::endl;
407 std::cout <<
"Adding event " << evtno <<
", clock 0x" << std::hex << bclk << std::dec
408 <<
" snglinput: " << prdfin->
Name() << std::endl;
432 std::cout <<
PHWHERE <<
" No reference input manager given" << std::endl;
435 std::map<SinglePrdfInput *, std::map<int, int>> clockcounters;
439 for (
auto veciter : iter.second)
444 std::cout <<
"diffclk for " << veciter.second->Name() <<
": " << std::hex
445 << diffclk <<
", clk: 0x" << veciter.first
446 <<
", refclk: 0x" << refclock << std::dec << std::endl;
448 auto clkiter = clockcounters.find(veciter.second);
449 if (clkiter == clockcounters.end())
451 std::map<int, int> mymap;
452 clkiter = clockcounters.insert(std::make_pair(veciter.second, mymap)).first;
454 clkiter->second[diffclk]++;
458 for (
const auto &iter : clockcounters)
461 int diffmax = INT_MAX;
462 for (
auto initer : iter.second)
466 std::cout << iter.first->Name() <<
" initer.second " << initer.second << std::hex
467 <<
" initer.first: " << initer.first << std::dec << std::endl;
469 if (initer.second > imax)
471 diffmax = initer.first;
472 imax = initer.second;
481 std::cout <<
"prdf mgr " << iter.first->Name() <<
" clkdiff: 0x" << std::hex
482 << iter.second.bclkoffset << std::dec << std::endl;
489 int diffclk = (bclk1 - bclk2) & 0xFFFF;
497 std::cout <<
"Killing event " << eventno << std::endl;
506 for (
auto const &pktiter : pktinfoiter->second.PacketVector)
528 std::map<SinglePrdfInput *, LocalInfo> matchevent;
529 std::vector<int> ditchevents;
534 std::cout <<
"looking for matching event " << iter.first
535 << std::hex <<
" with clk 0x" << iter.second << std::dec << std::endl;
541 std::cout <<
"testing for matching with event " << clockiter.first << std::endl;
543 for (
auto eventiter : clockiter.second)
545 int diffclock =
CalcDiffBclk(eventiter.first, iter.second);
548 std::cout <<
"Event " << iter.first <<
" match with event " << clockiter.first
549 <<
" clock 0x" << std::hex << eventiter.first <<
", ref clock 0x" << iter.second
550 <<
" diff 0x" << diffclock << std::dec
551 <<
" for " << eventiter.second->Name() << std::endl;
557 std::cout <<
"looking good for " << eventiter.second->Name() << std::endl;
559 matchevent[eventiter.second].clockcounter = clockiter.first;
560 matchevent[eventiter.second].eventdiff = clockiter.first - iter.first;
566 std::cout <<
"not so great for " << eventiter.second->Name() << std::endl;
574 std::cout <<
"found all matches" << std::endl;
583 std::cout <<
"found all matches" << std::endl;
587 ditchevents.push_back(iter.first);
589 for (
auto ievent : ditchevents)
593 int minoffset = INT_MAX;
594 for (
auto matches : matchevent)
598 std::cout << matches.first->Name() <<
" update event offset with: " << matches.second.eventdiff
599 <<
", current offset : " << matches.first->EventNumberOffset()
600 <<
" would go to " << matches.first->EventNumberOffset() - matches.second.eventdiff << std::endl;
602 if (minoffset > matches.first->EventNumberOffset() - matches.second.eventdiff)
604 minoffset = matches.first->EventNumberOffset() - matches.second.eventdiff;
613 std::cout <<
"minoffset < 0: " << minoffset <<
" this will be interesting" << std::endl;
615 addoffset = -minoffset;
617 for (
auto matches : matchevent)
619 matches.first->EventNumberOffset(matches.first->EventNumberOffset() - matches.second.eventdiff + addoffset);
622 std::cout << matches.first->Name() <<
" update event offset to: " << matches.first->EventNumberOffset()
634 for (
auto const &pktiter : pktinfoiter.second.PacketVector)