219 std::cout <<
"Mismatch between number of ppg codes (" <<
fOdbPPGCodes.size() <<
") and durations ("
223 std::cout <<
"No ODB cycle read!" << std::endl;
225 std::cout <<
"ODB cycle: " <<
OdbCycleLength() / 1000000 <<
" s" << std::endl
226 <<
"Code Duration" << std::endl;
232 if(TString(opt).Contains(
"odb", TString::ECaseCompare::kIgnoreCase)) {
236 std::cout <<
"Empty" << std::endl;
239 if(TString(opt).Contains(
"all", TString::ECaseCompare::kIgnoreCase)) {
241 PPGMap_t::iterator ppgit;
242 std::cout <<
"*****************************" << std::endl;
243 std::cout <<
" PPG STATUS " << std::endl;
244 std::cout <<
"*****************************" << std::endl;
246 ppgit->second->Print();
252 std::map<EPpgPattern, int> status;
253 std::map<ULong64_t, int> numberOfCycleLengths;
254 std::array<std::map<ULong64_t, int>, 4> numberOfStateLengths;
255 std::map<int, int> numberOfOffsets;
257 status[ppgIt->second->GetNewPPG()]++;
258 ULong64_t diff = ppgIt->second->GetTimeStamp() -
GetLastStatusTime(ppgIt->second->GetTimeStamp());
259 numberOfCycleLengths[diff]++;
260 numberOfOffsets[
static_cast<int>(ppgIt->second->GetTimeStamp() % 1000)]++;
261 switch(ppgIt->second->GetNewPPG()) {
264 numberOfStateLengths[0][diff]++;
268 numberOfStateLengths[1][diff]++;
272 numberOfStateLengths[2][diff]++;
276 numberOfStateLengths[3][diff]++;
282 ULong64_t cycleLength = 0;
283 for(
auto& numberOfCycleLength : numberOfCycleLengths) {
284 if(numberOfCycleLength.second > counter) {
285 counter = numberOfCycleLength.second;
286 cycleLength = numberOfCycleLength.first;
289 std::array<ULong64_t, 4> stateLength = {0, 0, 0, 0};
290 for(
int i = 0; i < 4; ++i) {
292 for(
auto it = numberOfStateLengths[i].begin(); it != numberOfStateLengths[i].end(); ++it) {
293 if(it->second > counter) {
294 counter = it->second;
295 stateLength[i] = it->first;
301 for(
auto& numberOfOffset : numberOfOffsets) {
302 if(numberOfOffset.second > counter) {
303 counter = numberOfOffset.second;
304 offset = numberOfOffset.first;
309 std::cout <<
"Cycle length is " << cycleLength <<
" in ns = " << cycleLength / 1000000000 <<
" seconds." << std::endl;
310 std::cout <<
"Cycle: " << stateLength[0] / 1000000000 <<
" s tape move, " << stateLength[1] / 1000000000 <<
" s background, " << stateLength[2] / 1000000000 <<
" s beam on, and " << stateLength[3] / 1000000000 <<
" s decay" << std::endl;
311 std::cout <<
"Offset is " << offset <<
" [ns]" << std::endl;
312 std::cout <<
"Got " <<
fPPGStatusMap->size() - 1 <<
" PPG words:" << std::endl;
313 for(
auto& statu : status) {
314 std::cout <<
"\tfound status " <<
hex(
static_cast<std::underlying_type<EPpgPattern>::type
>(statu.first), 4) <<
" " << statu.second <<
" times" << std::endl;
317 if(TString(opt).Contains(
"missing", TString::ECaseCompare::kIgnoreCase)) {
319 ULong64_t time = offset;
322 ULong64_t lastTimeStamp = iter->second->GetTimeStamp();
323 for(
int cycle = 1; time < lastTimeStamp; ++cycle) {
325 std::cout <<
"Missing tape move status at " << std::setw(12) << time <<
" in " << cycle <<
". cycle, last tape move status came at " <<
GetLastStatusTime(time,
EPpgPattern::kTapeMove) <<
"." << std::endl;
328 std::cout <<
"Missing background status at " << std::setw(12) << time + stateLength[0] <<
" in " << cycle <<
". cycle, last background status came at " <<
GetLastStatusTime(time + cycleLength,
EPpgPattern::kBackground) <<
"." << std::endl;
331 std::cout <<
"Missing beam on status at " << std::setw(12) << time + stateLength[0] + stateLength[1] <<
" in " << cycle <<
". cycle, last beam on status came at " <<
GetLastStatusTime(time + cycleLength,
EPpgPattern::kBeamOn) <<
"." << std::endl;
334 std::cout <<
"Missing decay status at " << std::setw(12) << time + stateLength[0] + stateLength[1] + stateLength[2] <<
" in " << cycle <<
". cycle, last decay status came at " <<
GetLastStatusTime(time + cycleLength,
EPpgPattern::kDecay) <<
"." << std::endl;
387 std::array<std::map<ULong64_t, int>, 4> numberOfStateLengths;
390 switch(ppgIt->second->GetNewPPG()) {
393 numberOfStateLengths[0][diff]++;
397 numberOfStateLengths[1][diff]++;
401 numberOfStateLengths[2][diff]++;
405 numberOfStateLengths[3][diff]++;
412 for(
int i = 0; i < 4; ++i) {
414 if(verbose) { std::cout <<
"state " <<
hex(
fPPGCodes[i], 4) <<
" checking " << numberOfStateLengths[i].size() <<
" lengths:"; }
415 for(
auto it : numberOfStateLengths[i]) {
416 if(it.second > counter) {
417 if(verbose) { std::cout <<
" " << it.second <<
">" << counter <<
" => fDurations[" << i <<
"] = " << it.first; }
421 std::cout <<
" " << it.second <<
"<" << counter <<
" => fDurations[" << i <<
"] != " << it.first;
424 if(verbose) { std::cout << std::endl; }
500 std::cout <<
"Found " << fNumberOfCycleLength.second <<
" wrong cycle length(s) of " << fNumberOfCycleLength.first <<
" (correct is " <<
fCycleLength <<
")." << std::endl;
513 ULong64_t diff = (*it).second->GetTimeStamp() -
GetLastStatusTime((*it).second->GetTimeStamp());
516 std::cout << std::distance(
MapBegin(), it) <<
": found missing ppg at time " << (*it).first <<
" (" << diff <<
" != " <<
fCycleLength <<
")" << std::endl;
522 std::cout <<
DRED <<
"PPG is messed up, cycle length is " <<
fCycleLength <<
", but the previous event with the same status was " << diff <<
" ago!" <<
RESET_COLOR << std::endl;
532 if(it->second->GetNewPPG() == (++prev)->second->GetOldPPG()) {
533 (--prev)->second->SetNewPPG(it->second->GetNewPPG());
535 std::cout <<
DBLUE <<
"PPG at " << (*it).first -
fCycleLength <<
" already exist with status " <<
hex(
static_cast<std::underlying_type<EPpgPattern>::type
>(prev->second->GetNewPPG())) <<
" (current status is " <<
hex(
static_cast<std::underlying_type<EPpgPattern>::type
>(it->second->GetNewPPG())) <<
")." <<
RESET_COLOR << std::endl;
540 auto* new_data =
new TPPGData(*((*it).second));
542 new_data->SetHighTimeStamp(new_ts >> 28);
543 new_data->SetLowTimeStamp(new_ts & 0x0fffffff);
545 std::cout <<
"inserting new ppg data at " << new_data->GetTimeStamp() << std::endl;
547 it =
fPPGStatusMap->insert(std::make_pair(new_data->GetTimeStamp(), new_data)).first;
564 std::cout <<
"Found " << fNumberOfCycleLength.second <<
" wrong cycle length(s) of " << fNumberOfCycleLength.first <<
" (correct is " <<
fCycleLength <<
")." << std::endl;