Skip to content

Commit 0ef81f5

Browse files
committed
[roc-trig-monitor] Add CAL count
1 parent ecf0fdc commit 0ef81f5

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

src/CommandLineUtilities/ProgramTriggerMonitor.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class ProgramTriggerMonitor : public Program
7272
auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar);
7373

7474
std::ostringstream table;
75-
auto formatHeader = " %-12s %-15s %-12s %-15s %-12s %-15s %-12s %-12s\n";
76-
auto formatRow = " %-12s %-15.3f %-12s %-15.3f %-12s %-15.3f %-12s %-12s\n";
77-
auto formatRowUpdateable = " %-12s %-15.3f %-12s %-15.3f %-12s %-15.3f %-12s %-12s";
78-
auto header = (boost::format(formatHeader) % "HB" % "HB rate (kHz)" % "PHY" % "PHY rate (kHz)" % "TOF" % "TOF rate (kHz)" % "SOX" % "EOX").str();
75+
auto formatHeader = " %-12s %-15s %-12s %-15s %-12s %-15s %-12s %-15s %-12s %-12s\n";
76+
auto formatRow = " %-12s %-15.3f %-12s %-15.3f %-12s %-15.3f %-12s %-15.3f %-12s %-12s\n";
77+
auto formatRowUpdateable = " %-12s %-15.3f %-12s %-15.3f %-12s %-15.3f %-12s %-15.3f %-12s %-12s";
78+
auto header = (boost::format(formatHeader) % "HB" % "HB rate (kHz)" % "PHY" % "PHY rate (kHz)" % "CAL" % "CAL rate (kHz)" % "TOF" % "TOF rate (kHz)" % "SOX" % "EOX").str();
7979
auto lineFat = std::string(header.length(), '=') + '\n';
8080
auto lineThin = std::string(header.length(), '-') + '\n';
8181

@@ -90,15 +90,15 @@ class ProgramTriggerMonitor : public Program
9090

9191
while (!isSigInt()) {
9292
Cru::TriggerMonitoringInfo tmi = cruBar2->monitorTriggers(true);
93-
auto format = boost::format(formatRowUpdateable) % tmi.hbCount % tmi.hbRate % tmi.phyCount % tmi.phyRate % tmi.tofCount % tmi.tofRate % tmi.soxCount % tmi.eoxCount;
93+
auto format = boost::format(formatRowUpdateable) % tmi.hbCount % tmi.hbRate % tmi.phyCount % tmi.phyRate % tmi.calCount % tmi.calRate % tmi.tofCount % tmi.tofRate % tmi.soxCount % tmi.eoxCount;
9494
std::cout << '\r' << format << std::flush;
9595
}
9696

9797
std::cout << std::endl
9898
<< lineFat;
9999
} else {
100100
Cru::TriggerMonitoringInfo tmi = cruBar2->monitorTriggers();
101-
auto format = boost::format(formatRow) % tmi.hbCount % tmi.hbRate % tmi.phyCount % tmi.phyRate % tmi.tofCount % tmi.tofRate % tmi.soxCount % tmi.eoxCount;
101+
auto format = boost::format(formatRow) % tmi.hbCount % tmi.hbRate % tmi.phyCount % tmi.phyRate % tmi.calCount % tmi.calRate % tmi.tofCount % tmi.tofRate % tmi.soxCount % tmi.eoxCount;
102102
table << format << lineFat;
103103
std::cout << table.str();
104104
}

src/Cru/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ struct TriggerMonitoringInfo {
176176
double phyRate;
177177
uint64_t tofCount;
178178
double tofRate;
179+
uint64_t calCount;
180+
double calRate;
179181
uint64_t eoxCount;
180182
uint64_t soxCount;
181183
};

src/Cru/Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ static constexpr Register ONU_MGT_STICKYS(0x00222014);
224224
static constexpr Register LTU_HBTRIG_CNT(0x00200004);
225225
static constexpr Register LTU_PHYSTRIG_CNT(0x00200008);
226226
static constexpr Register LTU_TOFTRIG_CNT(0x00200018);
227+
static constexpr Register LTU_CALTRIG_CNT(0x00200018);
227228
static constexpr Register LTU_EOX_SOX_CNT(0x0020000c);
228229

229230
//** GBT **//

src/Cru/CruBar.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,13 @@ Cru::TriggerMonitoringInfo CruBar::monitorTriggers(bool updateable)
616616
uint32_t hbCountPrev = ttc.getHbTriggerLtuCount();
617617
uint32_t phyCountPrev = ttc.getPhyTriggerLtuCount();
618618
uint32_t tofCountPrev = ttc.getTofTriggerLtuCount();
619+
uint32_t calCountPrev = ttc.getCalTriggerLtuCount();
619620

620621
// base values to report relative counts for updateable monitoring (e.g. for a single run)
621622
static uint32_t hbCountBase = hbCountPrev;
622623
static uint32_t phyCountBase = phyCountPrev;
623624
static uint32_t tofCountBase = tofCountPrev;
625+
static uint32_t calCountBase = calCountPrev;
624626
static std::pair<uint32_t, uint32_t> statEoxSox = ttc.getEoxSoxLtuCount();
625627
static uint32_t eoxCountBase = statEoxSox.first;
626628
static uint32_t soxCountBase = statEoxSox.second;
@@ -629,6 +631,7 @@ Cru::TriggerMonitoringInfo CruBar::monitorTriggers(bool updateable)
629631
uint32_t hbCount = ttc.getHbTriggerLtuCount();
630632
uint32_t phyCount = ttc.getPhyTriggerLtuCount();
631633
uint32_t tofCount = ttc.getTofTriggerLtuCount();
634+
uint32_t calCount = ttc.getCalTriggerLtuCount();
632635
std::pair<uint32_t, uint32_t> eoxSox = ttc.getEoxSoxLtuCount();
633636
uint32_t eoxCount = eoxSox.first;
634637
uint32_t soxCount = eoxSox.second;
@@ -655,11 +658,19 @@ Cru::TriggerMonitoringInfo CruBar::monitorTriggers(bool updateable)
655658
tofDiff = tofCount - tofCountPrev;
656659
}
657660

661+
uint64_t calDiff;
662+
if (calCountPrev > calCount) {
663+
calDiff = calCount + pow(2, 16) - calCountPrev;
664+
} else {
665+
calDiff = calCount - calCountPrev;
666+
}
667+
658668
// report absolute values + rates(1s)
659669
if (!updateable) {
660670
return { hbCount, hbDiff / pow(10, 3),
661671
phyCount, phyDiff / pow(10, 3),
662672
tofCount, tofDiff / pow(10, 3),
673+
calCount, calDiff / pow(10, 3),
663674
eoxCount, soxCount };
664675
}
665676

@@ -682,6 +693,7 @@ Cru::TriggerMonitoringInfo CruBar::monitorTriggers(bool updateable)
682693
return { hbCount - hbCountBase, hbDiff / pow(10, 3),
683694
phyCount - phyCountBase, phyDiff / pow(10, 3),
684695
tofCount - tofCountBase, tofDiff / pow(10, 3),
696+
calCount - calCountBase, calDiff / pow(10, 3),
685697
eoxDiff, soxDiff };
686698
}
687699

src/Cru/Ttc.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,12 @@ std::pair<uint32_t, uint32_t> Ttc::getEoxSoxLtuCount()
298298

299299
uint32_t Ttc::getTofTriggerLtuCount()
300300
{
301-
return mBar->readRegister(Cru::Registers::LTU_TOFTRIG_CNT.index);
301+
return mBar->readRegister(Cru::Registers::LTU_TOFTRIG_CNT.index) & 0xffff;
302+
}
303+
304+
uint32_t Ttc::getCalTriggerLtuCount()
305+
{
306+
return mBar->readRegister(Cru::Registers::LTU_CALTRIG_CNT.index) >> 16;
302307
}
303308

304309
/*** CTP EMULATOR METHODS ***/

src/Cru/Ttc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Ttc
4646
uint32_t getHbTriggerLtuCount();
4747
uint32_t getPhyTriggerLtuCount();
4848
uint32_t getTofTriggerLtuCount();
49+
uint32_t getCalTriggerLtuCount();
4950
std::pair<uint32_t, uint32_t> getEoxSoxLtuCount();
5051

5152
void resetCtpEmulator(bool doReset);

0 commit comments

Comments
 (0)