Skip to content

Commit c5b850d

Browse files
committed
Merge branch 'release/v09_18_01_02'
2 parents 83bb77d + 373485a commit c5b850d

5 files changed

Lines changed: 123 additions & 24 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
1515

1616
find_package(cetmodules 3.20.00 REQUIRED)
17-
project(sbnobj VERSION 09.18.01.01 LANGUAGES CXX)
17+
project(sbnobj VERSION 09.18.01.02 LANGUAGES CXX)
1818

1919
message(STATUS
2020
"\n-- ============================================================================="

sbnobj/Common/Trigger/BeamBits.h

Lines changed: 46 additions & 6 deletions
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.
@@ -137,8 +148,11 @@ namespace sbn {
137148

138149
/// Trigger window mode
139150
enum class triggerWindowMode: unsigned int {
140-
Separated, ///< Separated, non-overlapping contigous window
141-
Overlapping, ///< Overlaping windows
151+
Separated, ///< Separated, non-overlapping contiguous window.
152+
Overlapping, ///< Overlapping windows.
153+
SeparatedPlusAdders, ///< OR of `Separated` and `Adders`.
154+
OverlappingPlusAdders, ///< OR of `Overlapping` and `Adders`.
155+
Adders, ///< Trigger from adders.
142156
//==> add here if more are needed <==
143157
NBits ///< Number of Bits currently supported
144158
};
@@ -177,11 +191,13 @@ namespace sbn {
177191
std::string bitName(triggerSource bit);
178192
/// Returns a mnemonic short name of the trigger location.
179193
std::string bitName(triggerLocation bit);
194+
/// Returns a mnemonic short name of the trigger logic.
195+
std::string bitName(triggerLogic bit);
180196
/// Returns a mnemonic short name of the trigger type.
181197
std::string bitName(triggerType bit);
182198
/// Returns a mnemonic short name for the trigger window mode.
183199
std::string bitName(triggerWindowMode bit);
184-
/// Returns a mnemonic short name for the trigger window mode.
200+
/// Returns a mnemonic short name for the gate type.
185201
std::string bitName(gateSelection bit);
186202

187203
/// @}
@@ -193,6 +209,8 @@ namespace sbn {
193209
using bits::triggerSourceMask;
194210
using bits::triggerType;
195211
using bits::triggerTypeMask;
212+
using bits::triggerLogic;
213+
using bits::triggerLogicMask;
196214
using bits::triggerLocation;
197215
using bits::triggerLocationMask;
198216
using bits::triggerWindowMode;
@@ -280,8 +298,8 @@ inline std::string sbn::bits::bitName(triggerSource bit) {
280298
+ std::to_string(value(bit)) + " }): unknown bit"s);
281299
} // sbn::bitName()
282300

283-
// -----------------------------------------------------------------------------
284301

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

287305
using namespace std::string_literals;
@@ -298,6 +316,21 @@ inline std::string sbn::bits::bitName(triggerLocation bit) {
298316
+ std::to_string(value(bit)) + " }): unknown bit"s);
299317
} // sbn::bitName(triggerLocation)
300318

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+
301334
// -----------------------------------------------------------------------------
302335
inline std::string sbn::bits::bitName(triggerType bit) {
303336

@@ -311,19 +344,25 @@ inline std::string sbn::bits::bitName(triggerType bit) {
311344
+ std::to_string(value(bit)) + " }): unknown bit"s);
312345
} // sbn::bitName(triggerType)
313346

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

316351
using namespace std::string_literals;
317352
switch (bit) {
318-
case sbn::bits::triggerWindowMode::Separated: return "Separated Window"s;
319-
case sbn::bits::triggerWindowMode::Overlapping: return "Overlapping Window"s;
353+
case sbn::bits::triggerWindowMode::Separated: return "Separated Window"s;
354+
case sbn::bits::triggerWindowMode::Overlapping: return "Overlapping Window"s;
355+
case sbn::bits::triggerWindowMode::SeparatedPlusAdders: return "Separated Both"s;
356+
case sbn::bits::triggerWindowMode::OverlappingPlusAdders: return "Overlapping Both"s;
357+
case sbn::bits::triggerWindowMode::Adders: return "Adders"s;
320358
case sbn::bits::triggerWindowMode::NBits: return "<invalid>"s;
321359
} // switch
322360
throw std::runtime_error("sbn::bits::bitName(triggerWindowMode{ "s
323361
+ std::to_string(value(bit)) + " }): unknown bit"s);
324362
} // triggerWindowMode
325363

326364

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

329368
using namespace std::string_literals;
@@ -355,6 +394,7 @@ inline std::string sbn::bits::bitName(gateSelection bit) {
355394
} // sbn::bitName()
356395

357396

397+
// -----------------------------------------------------------------------------
358398
namespace icarus::trigger {
359399

360400
using triggerLocation = sbn::triggerLocation;

sbnobj/Common/Trigger/ExtraTriggerInfo.cxx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,35 +211,47 @@ 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])
219225
<< ", sectors: "
220-
<< dumpBits(cryo.SectorStatus[ExtraTriggerInfo::EastPMTwall], 6)
226+
<< dumpBits(cryo.sectorStatus[ExtraTriggerInfo::EastPMTwall], 6)
221227
<< "\n west wall: "
222228
<< dumpLVDSmask(cryo.LVDSstatus[ExtraTriggerInfo::WestPMTwall])
223229
<< ", sectors: "
224-
<< dumpBits(cryo.SectorStatus[ExtraTriggerInfo::WestPMTwall], 6)
230+
<< dumpBits(cryo.sectorStatus[ExtraTriggerInfo::WestPMTwall], 6)
225231
;
226232
}
227233

228234
out << "\nWest cryostat: "
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])
237249
<< ", sectors: "
238-
<< dumpBits(cryo.SectorStatus[ExtraTriggerInfo::EastPMTwall], 6)
250+
<< dumpBits(cryo.sectorStatus[ExtraTriggerInfo::EastPMTwall], 6)
239251
<< "\n west wall: "
240252
<< dumpLVDSmask(cryo.LVDSstatus[ExtraTriggerInfo::WestPMTwall])
241253
<< ", sectors: "
242-
<< dumpBits(cryo.SectorStatus[ExtraTriggerInfo::WestPMTwall], 6)
254+
<< dumpBits(cryo.sectorStatus[ExtraTriggerInfo::WestPMTwall], 6)
243255
;
244256
}
245257

sbnobj/Common/Trigger/ExtraTriggerInfo.h

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,44 @@ struct sbn::ExtraTriggerInfo {
238238
*
239239
* The remaining 10 bits are reserved for future use.
240240
*/
241-
std::array<std::uint16_t, MaxWalls> SectorStatus { 0U, 0U };
241+
std::array<std::uint16_t, MaxWalls> sectorStatus { 0U, 0U };
242+
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 }; }
242263

243264
/// Returns whether there is some recorded LVDS activity.
244265
constexpr bool hasLVDS() const;
245266

267+
/// Returns whether there is some recorded sector activity.
268+
constexpr bool hasSectors() const;
269+
270+
/// Returns whether there is some recorded activity (LVDS or sector).
271+
constexpr bool hasAnyActivity() const;
272+
246273
}; // CryostatInfo
247274

248275

249-
/// Bits for the trigger location (@see `triggerLocation()`).
276+
/// Bits for the trigger location (see `triggerLocation()`).
250277
unsigned int triggerLocationBits { 0U };
251-
//sbn::triggerLocation triggerLocationBits { sbn::triggerSource::NBits }
278+
252279
/// Status of each LVDS channel in each PMT wall at trigger time.
253280
std::array<CryostatInfo, MaxCryostats> cryostats;
254281

@@ -282,7 +309,7 @@ struct sbn::ExtraTriggerInfo {
282309
/// Returns sector states on a PMT `wall` of the specified `cryostat`.
283310
/// @throws std::out_of_range if invalid `cryostat` or `wall`
284311
std::uint16_t SectorInfo(std::size_t cryostat, std::size_t wall) const
285-
{ return cryostatInfo(cryostat).SectorStatus.at(wall); }
312+
{ return cryostatInfo(cryostat).sectorStatus.at(wall); }
286313

287314
/// @}
288315
// --- END ---- Trigger topology ---------------------------------------------
@@ -321,16 +348,34 @@ namespace sbn {
321348
std::ostream& operator<< (std::ostream& out, ExtraTriggerInfo const& info);
322349
}
323350

324-
// -----------------------------------------------------------------------------
325351

326-
constexpr bool sbn::ExtraTriggerInfo::CryostatInfo::hasLVDS() const {
352+
// -----------------------------------------------------------------------------
353+
inline constexpr bool sbn::ExtraTriggerInfo::CryostatInfo::hasLVDS() const {
327354
// C++20:
328-
// return std::ranges::any_of(LVDSstatus, std::identity{});
355+
// return std::ranges::any_of(LVDSstatus, std::identity{});
329356
for (std::uint64_t bits: LVDSstatus) if (bits) return true;
330357
return false;
331-
} // sbn::ExtraTriggerInfo::CryostatInfo::empty()
358+
} // sbn::ExtraTriggerInfo::CryostatInfo::hasLVDS()
359+
360+
361+
// -----------------------------------------------------------------------------
362+
inline constexpr bool sbn::ExtraTriggerInfo::CryostatInfo::hasSectors() const {
363+
// C++20:
364+
// return std::ranges::any_of(SectorStatus, std::identity{});
365+
for (std::uint64_t bits: sectorStatus) if (bits) return true;
366+
return false;
367+
} // sbn::ExtraTriggerInfo::CryostatInfo::hasSectors()
368+
332369

370+
// -----------------------------------------------------------------------------
371+
inline constexpr bool sbn::ExtraTriggerInfo::CryostatInfo::hasAnyActivity()
372+
const
373+
{
374+
return hasLVDS() || hasSectors();
375+
} // sbn::ExtraTriggerInfo::CryostatInfo::hasAnyActivity()
333376

334377

378+
// -----------------------------------------------------------------------------
379+
335380

336381
#endif // SBNOBJ_COMMON_TRIGGER_EXTRATRIGGERINFO_H

sbnobj/Common/Trigger/classes_def.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
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="11" >
30+
<class name="sbn::ExtraTriggerInfo::CryostatInfo" ClassVersion="13" >
31+
<version ClassVersion="13" checksum="2956313925"/>
32+
<version ClassVersion="12" checksum="804951501"/>
3133
<version ClassVersion="11" checksum="3455337645"/>
3234
<version ClassVersion="10" checksum="313789291"/>
3335
</class>

0 commit comments

Comments
 (0)