13 #ifndef SBNOBJ_COMMON_TRIGGER_BEAMBITS_H
14 #define SBNOBJ_COMMON_TRIGGER_BEAMBITS_H
21 #include <initializer_list>
22 #include <type_traits>
53 template <
typename EnumType>
62 template <
typename EnumType>
64 (
typename mask_t<EnumType>::maskbits_t bits) noexcept;
68 template <
typename EnumType>
69 constexpr
auto value(EnumType bit);
72 template <
typename EnumType,
typename... OtherBits>
73 constexpr mask_t<EnumType>
mask(EnumType bit, OtherBits... otherBits);
76 template <
typename EnumType>
77 constexpr
bool hasBitSet(mask_t<EnumType> bitMask, EnumType bit);
80 template <
typename EnumType>
81 std::string
name(EnumType bit);
85 template <
typename EnumType>
86 std::vector<std::string>
names(mask_t<EnumType>
mask);
207 template <
typename EnumType>
214 template <
typename EnumType>
216 {
return static_cast<std::underlying_type_t<EnumType>
>(bit); }
220 template <
typename EnumType,
typename... OtherBits>
224 unsigned int m { 1U <<
value(bit) };
225 if constexpr(
sizeof...(OtherBits) > 0U)
m |=
mask(otherBits...);
231 template <
typename EnumType>
233 {
return bitMask &
mask(bit); }
237 template <
typename EnumType>
243 template <
typename EnumType>
245 static_assert(
value(EnumType::NBits) >= 0);
247 using namespace std::string_literals;
249 constexpr std::size_t MaxBits =
sizeof(
mask) * 8U;
250 constexpr std::size_t NSupportedBits =
value(EnumType::NBits);
252 std::vector<std::string>
names;
253 for (std::size_t bit = 0U; bit < MaxBits; ++bit) {
254 auto const typedBit =
static_cast<EnumType
>(bit);
255 if (!
hasBitSet(mask, typedBit))
continue;
256 names.push_back((bit > NSupportedBits)
269 using namespace std::string_literals;
271 case triggerSource::Unknown:
return "unknown"s;
272 case triggerSource::BNB:
return "BNB"s;
273 case triggerSource::NuMI:
return "NuMI"s;
274 case triggerSource::OffbeamBNB:
return "OffbeamBNB"s;
275 case triggerSource::OffbeamNuMI:
return "OffbeamNuMI"s;
276 case triggerSource::Calib:
return "Calib"s;
277 case triggerSource::NBits:
return "<invalid>"s;
279 throw std::runtime_error(
"sbn::bits::bitName(triggerSource{ "s
287 using namespace std::string_literals;
289 case triggerLocation::CryoEast:
return "Cryo E"s;
290 case triggerLocation::CryoWest:
return "Cryo W"s;
291 case triggerLocation::TPCEE:
return "TPC EE"s;
292 case triggerLocation::TPCEW:
return "TPC EW"s;
293 case triggerLocation::TPCWE:
return "TPC WE"s;
294 case triggerLocation::TPCWW:
return "TPC WW"s;
295 case triggerLocation::NBits:
return "<invalid>"s;
297 throw std::runtime_error(
"sbn::bits::bitName(triggerLocation{ "s
304 using namespace std::string_literals;
306 case triggerType::Majority:
return "majority"s;
307 case triggerType::MinimumBias:
return "minimum bias"s;
308 case triggerType::NBits:
return "<invalid>"s;
310 throw std::runtime_error(
"sbn::bits::bitName(triggerType{ "s
316 using namespace std::string_literals;
322 throw std::runtime_error(
"sbn::bits::bitName(triggerWindowMode{ "s
329 using namespace std::string_literals;
331 case gateSelection::GateBNB:
return "GateBNB"s;
332 case gateSelection::DriftGateBNB:
return "DriftGateBNB"s;
333 case gateSelection::GateNuMI:
return "GateNuMI"s;
334 case gateSelection::DriftGateNuMI:
return "DriftGateNuMI"s;
335 case gateSelection::GateOffbeamBNB:
return "GateOffbeamBNB"s;
336 case gateSelection::DriftGateOffbeamBNB:
return "DriftGateOffbeamBNB"s;
337 case gateSelection::GateOffbeamNuMI:
return "GateOffbeamNuMI"s;
338 case gateSelection::DriftGateOffbeamNuMI:
return "DriftGateOffbeamNuMI"s;
339 case gateSelection::GateCalibration:
return "GateCalibration"s;
340 case gateSelection::DriftGateCalibration:
return "DriftGateCalibration"s;
341 case gateSelection::MinbiasGateBNB:
return "MinbiasGateBNB"s;
342 case gateSelection::MinbiasGateNuMI:
return "MinbiasGateNuMI"s;
343 case gateSelection::MinbiasGateOffbeamBNB:
return "MinbiasGateOffbeamBNB"s;
344 case gateSelection::MinbiasGateOffbeamNuMI:
return "MinbiasGateOffbeamNuMI"s;
345 case gateSelection::MinbiasGateCalibration:
return "MinbiasGateCalibration"s;
346 case gateSelection::MinbiasDriftGateBNB:
return "MinbiasDriftGateBNB"s;
347 case gateSelection::MinbiasDriftGateNuMI:
return "MinbiasDriftGateNuMI"s;
348 case gateSelection::MinbiasDriftGateOffbeamBNB:
return "MinbiasDriftGateOffbeamBNB"s;
349 case gateSelection::MinbiasDriftGateOffbeamNuMI:
return "MinbiasDriftGateOffbeamNuMI"s;
350 case gateSelection::MinbiasDriftGateCalibration:
return "MinbiasDriftGateCalibration"s;
351 case gateSelection::NBits:
return "NBits"s;
353 throw std::runtime_error(
"sbn::bits::bitName(gateSelection{ "s
358 namespace icarus::trigger {
363 static constexpr std::size_t
kEast = sbn::bits::value<triggerLocation>(triggerLocation::CryoEast);
364 static constexpr std::size_t
kWest = sbn::bits::value<triggerLocation>(triggerLocation::CryoWest);
365 static constexpr std::size_t
kNTriggerLocation = sbn::bits::value<triggerLocation>(triggerLocation::NBits);
367 static constexpr std::size_t
kBNB = sbn::bits::value<triggerSource>(triggerSource::BNB);
368 static constexpr std::size_t
kNuMI = sbn::bits::value<triggerSource>(triggerSource::NuMI);
369 static constexpr std::size_t
kOffBeamBNB = sbn::bits::value<triggerSource>(triggerSource::OffbeamBNB);
370 static constexpr std::size_t
kOffBeamNuMI = sbn::bits::value<triggerSource>(triggerSource::OffbeamNuMI);
371 static constexpr std::size_t
kCalibration = sbn::bits::value<triggerSource>(triggerSource::Calib);
372 static constexpr std::size_t
kNTriggerSource = sbn::bits::value<triggerSource>(triggerSource::NBits);
379 #endif // SBNOBJ_COMMON_TRIGGER_BEAMBITS_H
std::string name(EnumType bit)
Returns the name of the specified bit. Delegates to bitName().
Number of bits currently supported.
sbn::triggerSource triggerSource
static constexpr std::size_t kOffBeamNuMI
static constexpr std::size_t kWest
Enabke MinBias triggers for the Offbeam BNB stream.
Enable MinBias triggers for the Calibration stream.
constexpr bool hasBitSet(mask_t< EnumType > bitMask, EnumType bit)
Returns whether the specified bit is set in bitMask.
constexpr auto value(EnumType bit)
Returns the value of specified bit (conversion like enum to int).
Separated, non-overlapping contigous window.
mask_t< triggerLocation > triggerLocationMask
Type of mask with triggerLocation bits.
Enable Offbeam drift gate NuMI (for light out-of-time in offbeam gates)
gateSelection
Enabled gates in the trigger configuration. See register 0X00050008 in docdb SBN-doc-23778-v1.
std::underlying_type_t< EnumType > maskbits_t
Bit data type.
triggerWindowMode
Trigger window mode.
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
static constexpr std::size_t kBNB
Data collected at gate opening with no further requirement imposed.
static constexpr std::size_t kNTriggerSource
A minimum number of close-by PMT pairs above threshold was reached.
triggerLocation
Location or locations generating a trigger.
static constexpr std::size_t kNTriggerLocation
Enable NuMI early warning signal (MIBS$74) to open NuMI gates.
std::string bitName(triggerSource bit)
Returns a mnemonic short name of the beam type.
Enable light out-of-time for MinBias triggers in NuMI stream.
Enable light out-of-time for MinBias triggers in BNB stream.
Enable light out-of-time for MinBias triggers in Offbeam NuMI stream.
static constexpr std::size_t kCalibration
constexpr mask_t< EnumType > mask(EnumType bit, OtherBits...otherBits)
Returns a mask with all specified bits set.
sbn::triggerLocation triggerLocation
std::vector< std::string > names(mask_t< EnumType > mask)
A trigger happened in the east cryostat.
triggerType
Type representing the type(s) of this trigger.
Enable MinBias triggers for the Offbeam NuMI stream.
A trigger happened in the east cryostat, west TPC.
Enable Offbeam gate for BNB.
Type of source: calibration trigger.
A trigger happened in the west cryostat, west TPC.
static constexpr std::size_t kNuMI
static const std::vector< std::string > names
Enable Offbeam drift gate BNB (for light out-of-time in offbeam gates)
mask_t< EnumType > makeMask(typename mask_t< EnumType >::maskbits_t bits) noexcept
Converts a integral type into a mask.
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
Enable MinBias triggers for the BNB stream.
Enable Calibration drift gate (for light out-of-time in calibration gates)
static constexpr std::size_t kOffBeamBNB
A trigger happened in the east cryostat, east TPC.
mask_t< triggerSource > triggerSourceMask
Type of mask with triggerSource bits.
Enable Offbeam gate for NuMI.
Enable BNB early-early warning signal ($1D) for light out-of-time in BNB gates.
triggerSource
Type of beam or beam gate or other trigger source.
EnumType bits_t
Enumeration type of the bits.
Enable receiving NuMI early-early warning signal ($AD) for light out-of-time in NuMI gates...
mask_t< triggerType > triggerTypeMask
Type of mask with triggerType bits.
Enable MinBias triggers for the NuMI stream.
static constexpr std::size_t kEast
A trigger happened in the west cryostat.
Enable receiving BNB early warning signal (gatedBES) to open BNB gates.
Enable light out-of-time for MinBias triggers in Calibration stream.
Enable light out-of-time for MinBias triggers in Offbeam BNB stream.
A trigger happened in the west cryostat, east TPC.