Skip to content

Commit 48b5ece

Browse files
sbn::ExtraTriggerInfo: added trigger logic information
1 parent cc21610 commit 48b5ece

4 files changed

Lines changed: 74 additions & 6 deletions

File tree

sbnobj/Common/Trigger/BeamBits.h

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ namespace sbn {
124124
/// Type of mask with `triggerLocation` bits.
125125
using triggerLocationMask = mask_t<triggerLocation>;
126126

127+
/// Type(s) of trigger logic being satisfied.
128+
enum class triggerLogic: unsigned int {
129+
PMTAnalogSum, ///< Discriminated PMT signal sum above threshold.
130+
PMTPairMajority, ///< Minimum number of discriminated PMT above threshold.
131+
// ==> add here if more are needed <==
132+
NBits ///< Number of bits currently supported.
133+
}; // triggerLocation
134+
135+
/// Type of mask with `triggerLogic` bits.
136+
using triggerLogicMask = mask_t<triggerLogic>;
137+
127138
/// Type representing the type(s) of this trigger.
128139
enum class triggerType: unsigned int {
129140
Majority, ///< A minimum number of close-by PMT pairs above threshold was reached.
@@ -180,6 +191,8 @@ namespace sbn {
180191
std::string bitName(triggerSource bit);
181192
/// Returns a mnemonic short name of the trigger location.
182193
std::string bitName(triggerLocation bit);
194+
/// Returns a mnemonic short name of the trigger logic.
195+
std::string bitName(triggerLogic bit);
183196
/// Returns a mnemonic short name of the trigger type.
184197
std::string bitName(triggerType bit);
185198
/// Returns a mnemonic short name for the trigger window mode.
@@ -196,6 +209,8 @@ namespace sbn {
196209
using bits::triggerSourceMask;
197210
using bits::triggerType;
198211
using bits::triggerTypeMask;
212+
using bits::triggerLogic;
213+
using bits::triggerLogicMask;
199214
using bits::triggerLocation;
200215
using bits::triggerLocationMask;
201216
using bits::triggerWindowMode;
@@ -283,8 +298,8 @@ inline std::string sbn::bits::bitName(triggerSource bit) {
283298
+ std::to_string(value(bit)) + " }): unknown bit"s);
284299
} // sbn::bitName()
285300

286-
// -----------------------------------------------------------------------------
287301

302+
// -----------------------------------------------------------------------------
288303
inline std::string sbn::bits::bitName(triggerLocation bit) {
289304

290305
using namespace std::string_literals;
@@ -301,6 +316,21 @@ inline std::string sbn::bits::bitName(triggerLocation bit) {
301316
+ std::to_string(value(bit)) + " }): unknown bit"s);
302317
} // sbn::bitName(triggerLocation)
303318

319+
320+
// -----------------------------------------------------------------------------
321+
inline std::string sbn::bits::bitName(triggerLogic bit) {
322+
323+
using namespace std::string_literals;
324+
switch (bit) {
325+
case triggerLogic::PMTPairMajority: return "PMT pair majority"s;
326+
case triggerLogic::PMTAnalogSum: return "PMT analog sum"s;
327+
case triggerLogic::NBits: return "<invalid>"s;
328+
} // switch
329+
throw std::runtime_error("sbn::bits::bitName(triggerLogic{ "s
330+
+ std::to_string(value(bit)) + " }): unknown bit"s);
331+
} // sbn::bitName(triggerLogic)
332+
333+
304334
// -----------------------------------------------------------------------------
305335
inline std::string sbn::bits::bitName(triggerType bit) {
306336

@@ -314,6 +344,8 @@ inline std::string sbn::bits::bitName(triggerType bit) {
314344
+ std::to_string(value(bit)) + " }): unknown bit"s);
315345
} // sbn::bitName(triggerType)
316346

347+
348+
// -----------------------------------------------------------------------------
317349
inline std::string sbn::bits::bitName(triggerWindowMode bit) {
318350

319351
using namespace std::string_literals;
@@ -330,6 +362,7 @@ inline std::string sbn::bits::bitName(triggerWindowMode bit) {
330362
} // triggerWindowMode
331363

332364

365+
// -----------------------------------------------------------------------------
333366
inline std::string sbn::bits::bitName(gateSelection bit) {
334367

335368
using namespace std::string_literals;
@@ -361,6 +394,7 @@ inline std::string sbn::bits::bitName(gateSelection bit) {
361394
} // sbn::bitName()
362395

363396

397+
// -----------------------------------------------------------------------------
364398
namespace icarus::trigger {
365399

366400
using triggerLocation = sbn::triggerLocation;

sbnobj/Common/Trigger/ExtraTriggerInfo.cxx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,14 @@ std::ostream& sbn::operator<< (std::ostream& out, ExtraTriggerInfo const& info)
211211
<< info.cryostats[ExtraTriggerInfo::EastCryostat].triggerCount
212212
<< " triggers";
213213
if (auto const& cryo = info.cryostats[ExtraTriggerInfo::EastCryostat];
214-
cryo.hasLVDS()
215-
) {
214+
cryo.hasAnyActivity()
215+
) {
216+
out << "\n trigger logic: ";
217+
if (cryo.triggerLogicBits) {
218+
for (std::string const& bitName: names(cryo.triggerLogic()))
219+
out << " " << bitName;
220+
}
221+
else out << " none!";
216222
out
217223
<< "\n east wall: "
218224
<< dumpLVDSmask(cryo.LVDSstatus[ExtraTriggerInfo::EastPMTwall])
@@ -229,8 +235,14 @@ std::ostream& sbn::operator<< (std::ostream& out, ExtraTriggerInfo const& info)
229235
<< info.cryostats[ExtraTriggerInfo::WestCryostat].triggerCount
230236
<< " triggers";
231237
if (auto const& cryo = info.cryostats[ExtraTriggerInfo::WestCryostat];
232-
cryo.hasLVDS()
233-
) {
238+
cryo.hasAnyActivity()
239+
) {
240+
out << "\n trigger logic: ";
241+
if (cryo.triggerLogicBits) {
242+
for (std::string const& bitName: names(cryo.triggerLogic()))
243+
out << " * " << bitName;
244+
}
245+
else out << " none!";
234246
out
235247
<< "\n east wall: "
236248
<< dumpLVDSmask(cryo.LVDSstatus[ExtraTriggerInfo::EastPMTwall])

sbnobj/Common/Trigger/ExtraTriggerInfo.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,27 @@ struct sbn::ExtraTriggerInfo {
240240
*/
241241
std::array<std::uint16_t, MaxWalls> sectorStatus { 0U, 0U };
242242

243+
/// The type of logic that fired the first trigger in this cryostat.
244+
/// @see sbn::bits::triggerLogicMask
245+
unsigned int triggerLogicBits { 0U };
246+
247+
/**
248+
* @brief Returns the type of logic satisfied by the trigger.
249+
*
250+
* The returned value is a mask of `sbn::bits::triggerLogic` bits.
251+
* To test the state of a bit, it needs to be converted into a mask, e.g.:
252+
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
253+
* bool isFromAdders
254+
* = extraTriggerInfo.triggerLogic() & mask(sbn::triggerLogic::Adders);
255+
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
256+
*
257+
* Note that one trigger may have satisfied multiple logics within a time
258+
* close enough that the trigger is considered fired by all of them.
259+
* The "overlap" criterium is decided by the hardware.
260+
*/
261+
sbn::bits::triggerLogicMask triggerLogic() const
262+
{ return { triggerLogicBits }; }
263+
243264
/// Returns whether there is some recorded LVDS activity.
244265
constexpr bool hasLVDS() const;
245266

sbnobj/Common/Trigger/classes_def.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<enum name="sbn::bits::triggerSource" ClassVersion="10" />
2828
<enum name="sbn::bits::triggerLocation" ClassVersion="10" />
2929
<enum name="sbn::bits::triggerType" ClassVersion="10" />
30-
<class name="sbn::ExtraTriggerInfo::CryostatInfo" ClassVersion="12" >
30+
<class name="sbn::ExtraTriggerInfo::CryostatInfo" ClassVersion="13" >
31+
<version ClassVersion="13" checksum="2956313925"/>
3132
<version ClassVersion="12" checksum="804951501"/>
3233
<version ClassVersion="11" checksum="3455337645"/>
3334
<version ClassVersion="10" checksum="313789291"/>

0 commit comments

Comments
 (0)