217 std::cout <<
"Mismatch between number of ppg codes (" <<
fOdbPPGCodes.size() <<
") and durations ("
221 std::cout <<
"No ODB cycle read!" << std::endl;
223 std::cout <<
"ODB cycle: " <<
OdbCycleLength() / 1000000 <<
" s" << std::endl
224 <<
"Code Duration" << std::endl;
230 if(TString(opt).Contains(
"odb", TString::ECaseCompare::kIgnoreCase)) {
234 std::cout <<
"Empty" << std::endl;
237 if(TString(opt).Contains(
"all", TString::ECaseCompare::kIgnoreCase)) {
239 PPGMap_t::iterator ppgit;
240 std::cout <<
"*****************************" << std::endl;
241 std::cout <<
" PPG STATUS " << std::endl;
242 std::cout <<
"*****************************" << std::endl;
244 ppgit->second->Print();
250 std::map<EPpgPattern, int> status;
251 std::map<ULong64_t, int> numberOfCycleLengths;
252 std::array<std::map<ULong64_t, int>, 4> numberOfStateLengths;
253 std::map<int, int> numberOfOffsets;
255 status[ppgIt->second->GetNewPPG()]++;
256 ULong64_t diff = ppgIt->second->GetTimeStamp() -
GetLastStatusTime(ppgIt->second->GetTimeStamp());
257 numberOfCycleLengths[diff]++;
258 numberOfOffsets[
static_cast<int>(ppgIt->second->GetTimeStamp() % 1000)]++;
259 switch(ppgIt->second->GetNewPPG()) {
262 numberOfStateLengths[0][diff]++;
266 numberOfStateLengths[1][diff]++;
270 numberOfStateLengths[2][diff]++;
274 numberOfStateLengths[3][diff]++;
280 ULong64_t cycleLength = 0;
281 for(
auto& numberOfCycleLength : numberOfCycleLengths) {
282 if(numberOfCycleLength.second > counter) {
283 counter = numberOfCycleLength.second;
284 cycleLength = numberOfCycleLength.first;
287 std::array<ULong64_t, 4> stateLength = {0, 0, 0, 0};
288 for(
int i = 0; i < 4; ++i) {
290 for(
auto it = numberOfStateLengths[i].begin(); it != numberOfStateLengths[i].end(); ++it) {
291 if(it->second > counter) {
292 counter = it->second;
293 stateLength[i] = it->first;
299 for(
auto& numberOfOffset : numberOfOffsets) {
300 if(numberOfOffset.second > counter) {
301 counter = numberOfOffset.second;
302 offset = numberOfOffset.first;
307 std::cout <<
"Cycle length is " << cycleLength <<
" in ns = " << cycleLength / 1000000000 <<
" seconds." << std::endl;
308 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;
309 std::cout <<
"Offset is " << offset <<
" [ns]" << std::endl;
310 std::cout <<
"Got " <<
fPPGStatusMap->size() - 1 <<
" PPG words:" << std::endl;
311 for(
auto& statu : status) {
312 std::cout <<
"\tfound status " <<
hex(
static_cast<std::underlying_type<EPpgPattern>::type
>(statu.first), 4) <<
" " << statu.second <<
" times" << std::endl;
315 if(TString(opt).Contains(
"missing", TString::ECaseCompare::kIgnoreCase)) {
317 ULong64_t time = offset;
320 ULong64_t lastTimeStamp = iter->second->GetTimeStamp();
321 for(
int cycle = 1; time < lastTimeStamp; ++cycle) {
323 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;
326 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;
329 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;
332 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;
385 std::array<std::map<ULong64_t, int>, 4> numberOfStateLengths;
388 switch(ppgIt->second->GetNewPPG()) {
391 numberOfStateLengths[0][diff]++;
395 numberOfStateLengths[1][diff]++;
399 numberOfStateLengths[2][diff]++;
403 numberOfStateLengths[3][diff]++;
410 for(
int i = 0; i < 4; ++i) {
412 if(verbose) { std::cout <<
"state " <<
hex(
fPPGCodes[i], 4) <<
" checking " << numberOfStateLengths[i].size() <<
" lengths:"; }
413 for(
auto it : numberOfStateLengths[i]) {
414 if(it.second > counter) {
415 if(verbose) { std::cout <<
" " << it.second <<
">" << counter <<
" => fDurations[" << i <<
"] = " << it.first; }
419 std::cout <<
" " << it.second <<
"<" << counter <<
" => fDurations[" << i <<
"] != " << it.first;
422 if(verbose) { std::cout << std::endl; }
498 std::cout <<
"Found " << fNumberOfCycleLength.second <<
" wrong cycle length(s) of " << fNumberOfCycleLength.first <<
" (correct is " <<
fCycleLength <<
")." << std::endl;
511 ULong64_t diff = (*it).second->GetTimeStamp() -
GetLastStatusTime((*it).second->GetTimeStamp());
514 std::cout << std::distance(
MapBegin(), it) <<
": found missing ppg at time " << (*it).first <<
" (" << diff <<
" != " <<
fCycleLength <<
")" << std::endl;
520 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;
530 if(it->second->GetNewPPG() == (++prev)->second->GetOldPPG()) {
531 (--prev)->second->SetNewPPG(it->second->GetNewPPG());
533 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;
538 auto* new_data =
new TPPGData(*((*it).second));
540 new_data->SetHighTimeStamp(new_ts >> 28);
541 new_data->SetLowTimeStamp(new_ts & 0x0fffffff);
543 std::cout <<
"inserting new ppg data at " << new_data->GetTimeStamp() << std::endl;
545 it =
fPPGStatusMap->insert(std::make_pair(new_data->GetTimeStamp(), new_data)).first;
562 std::cout <<
"Found " << fNumberOfCycleLength.second <<
" wrong cycle length(s) of " << fNumberOfCycleLength.first <<
" (correct is " <<
fCycleLength <<
")." << std::endl;