All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes
sbn::bits Namespace Reference

Simple utilities to deal with bit enumerators. More...

Classes

struct  mask_t
 

Functions

Generic bit functions
template<typename EnumType >
mask_t< EnumType > makeMask (typename mask_t< EnumType >::maskbits_t bits) noexcept
 Converts a integral type into a mask. More...
 
template<typename EnumType >
constexpr auto value (EnumType bit)
 Returns the value of specified bit (conversion like enum to int). More...
 
template<typename EnumType , typename... OtherBits>
constexpr mask_t< EnumType > mask (EnumType bit, OtherBits...otherBits)
 Returns a mask with all specified bits set. More...
 
template<typename EnumType >
constexpr bool hasBitSet (mask_t< EnumType > bitMask, EnumType bit)
 Returns whether the specified bit is set in bitMask. More...
 
template<typename EnumType >
std::string name (EnumType bit)
 Returns the name of the specified bit. Delegates to bitName(). More...
 
template<typename EnumType >
std::vector< std::string > names (mask_t< EnumType > mask)
 

Beam bits

enum  triggerSource : unsigned int {
  triggerSource::Unknown, triggerSource::BNB, triggerSource::NuMI, triggerSource::OffbeamBNB,
  triggerSource::OffbeamNuMI, triggerSource::Calib, triggerSource::NBits
}
 Type of beam or beam gate or other trigger source. More...
 
enum  triggerLocation : unsigned int {
  triggerLocation::CryoEast, triggerLocation::CryoWest, triggerLocation::TPCEE, triggerLocation::TPCEW,
  triggerLocation::TPCWE, triggerLocation::TPCWW, triggerLocation::NBits
}
 Location or locations generating a trigger. More...
 
enum  triggerType : unsigned int { triggerType::Majority, triggerType::MinimumBias, triggerType::NBits }
 Type representing the type(s) of this trigger. More...
 
enum  triggerWindowMode : unsigned int { triggerWindowMode::Separated, triggerWindowMode::Overlapping, triggerWindowMode::NBits }
 Trigger window mode. More...
 
enum  gateSelection : unsigned int {
  gateSelection::GateBNB, gateSelection::DriftGateBNB, gateSelection::GateNuMI, gateSelection::DriftGateNuMI,
  gateSelection::GateOffbeamBNB, gateSelection::DriftGateOffbeamBNB, gateSelection::GateOffbeamNuMI, gateSelection::DriftGateOffbeamNuMI,
  gateSelection::GateCalibration, gateSelection::DriftGateCalibration, gateSelection::MinbiasGateBNB, gateSelection::MinbiasGateNuMI,
  gateSelection::MinbiasGateOffbeamBNB, gateSelection::MinbiasGateOffbeamNuMI, gateSelection::MinbiasGateCalibration, gateSelection::MinbiasDriftGateBNB,
  gateSelection::MinbiasDriftGateNuMI, gateSelection::MinbiasDriftGateOffbeamBNB, gateSelection::MinbiasDriftGateOffbeamNuMI, gateSelection::MinbiasDriftGateCalibration,
  gateSelection::NBits
}
 Enabled gates in the trigger configuration. See register 0X00050008 in docdb SBN-doc-23778-v1. More...
 
using triggerSourceMask = mask_t< triggerSource >
 Type of mask with triggerSource bits. More...
 
using triggerLocationMask = mask_t< triggerLocation >
 Type of mask with triggerLocation bits. More...
 
using triggerTypeMask = mask_t< triggerType >
 Type of mask with triggerType bits. More...
 
using gateSelectionMask = mask_t< gateSelection >
 
std::string bitName (triggerSource bit)
 Returns a mnemonic short name of the beam type. More...
 
std::string bitName (triggerLocation bit)
 Returns a mnemonic short name of the trigger location. More...
 
std::string bitName (triggerType bit)
 Returns a mnemonic short name of the trigger type. More...
 
std::string bitName (triggerWindowMode bit)
 Returns a mnemonic short name for the trigger window mode. More...
 
std::string bitName (gateSelection bit)
 Returns a mnemonic short name for the trigger window mode. More...
 

Detailed Description

Simple utilities to deal with bit enumerators.

A few simple concepts:

Typedef Documentation

Definition at line 174 of file BeamBits.h.

Type of mask with triggerLocation bits.

Definition at line 125 of file BeamBits.h.

Type of mask with triggerSource bits.

Definition at line 109 of file BeamBits.h.

Type of mask with triggerType bits.

Definition at line 136 of file BeamBits.h.

Enumeration Type Documentation

enum sbn::bits::gateSelection : unsigned int
strong

Enabled gates in the trigger configuration. See register 0X00050008 in docdb SBN-doc-23778-v1.

Enumerator
GateBNB 

Enable receiving BNB early warning signal (gatedBES) to open BNB gates.

DriftGateBNB 

Enable BNB early-early warning signal ($1D) for light out-of-time in BNB gates.

GateNuMI 

Enable NuMI early warning signal (MIBS$74) to open NuMI gates.

DriftGateNuMI 

Enable receiving NuMI early-early warning signal ($AD) for light out-of-time in NuMI gates.

GateOffbeamBNB 

Enable Offbeam gate for BNB.

DriftGateOffbeamBNB 

Enable Offbeam drift gate BNB (for light out-of-time in offbeam gates)

GateOffbeamNuMI 

Enable Offbeam gate for NuMI.

DriftGateOffbeamNuMI 

Enable Offbeam drift gate NuMI (for light out-of-time in offbeam gates)

GateCalibration 

Enable Calibration gate.

DriftGateCalibration 

Enable Calibration drift gate (for light out-of-time in calibration gates)

MinbiasGateBNB 

Enable MinBias triggers for the BNB stream.

MinbiasGateNuMI 

Enable MinBias triggers for the NuMI stream.

MinbiasGateOffbeamBNB 

Enabke MinBias triggers for the Offbeam BNB stream.

MinbiasGateOffbeamNuMI 

Enable MinBias triggers for the Offbeam NuMI stream.

MinbiasGateCalibration 

Enable MinBias triggers for the Calibration stream.

MinbiasDriftGateBNB 

Enable light out-of-time for MinBias triggers in BNB stream.

MinbiasDriftGateNuMI 

Enable light out-of-time for MinBias triggers in NuMI stream.

MinbiasDriftGateOffbeamBNB 

Enable light out-of-time for MinBias triggers in Offbeam BNB stream.

MinbiasDriftGateOffbeamNuMI 

Enable light out-of-time for MinBias triggers in Offbeam NuMI stream.

MinbiasDriftGateCalibration 

Enable light out-of-time for MinBias triggers in Calibration stream.

NBits 

Definition at line 149 of file BeamBits.h.

149  : unsigned int {
150  GateBNB, ///<Enable receiving BNB early warning signal (gatedBES) to open BNB gates
151  DriftGateBNB, ///<Enable BNB early-early warning signal ($1D) for light out-of-time in BNB gates
152  GateNuMI, ///<Enable NuMI early warning signal (MIBS$74) to open NuMI gates
153  DriftGateNuMI, ///<Enable receiving NuMI early-early warning signal ($AD) for light out-of-time in NuMI gates
154  GateOffbeamBNB, ///<Enable Offbeam gate for BNB
155  DriftGateOffbeamBNB, ///<Enable Offbeam drift gate BNB (for light out-of-time in offbeam gates)
156  GateOffbeamNuMI, ///<Enable Offbeam gate for NuMI
157  DriftGateOffbeamNuMI, ///<Enable Offbeam drift gate NuMI (for light out-of-time in offbeam gates)
158  GateCalibration, ///<Enable Calibration gate
159  DriftGateCalibration, ///<Enable Calibration drift gate (for light out-of-time in calibration gates)
160  MinbiasGateBNB, ///<Enable MinBias triggers for the BNB stream
161  MinbiasGateNuMI, ///<Enable MinBias triggers for the NuMI stream
162  MinbiasGateOffbeamBNB, ///<Enabke MinBias triggers for the Offbeam BNB stream
163  MinbiasGateOffbeamNuMI, ///<Enable MinBias triggers for the Offbeam NuMI stream
164  MinbiasGateCalibration, ///<Enable MinBias triggers for the Calibration stream
165  MinbiasDriftGateBNB, ///<Enable light out-of-time for MinBias triggers in BNB stream
166  MinbiasDriftGateNuMI, ///<Enable light out-of-time for MinBias triggers in NuMI stream
167  MinbiasDriftGateOffbeamBNB, ///<Enable light out-of-time for MinBias triggers in Offbeam BNB stream
168  MinbiasDriftGateOffbeamNuMI, ///<Enable light out-of-time for MinBias triggers in Offbeam NuMI stream
169  MinbiasDriftGateCalibration, ///<Enable light out-of-time for MinBias triggers in Calibration stream
170  // ==> add here if more are needed <==
171  NBits
172  }; // gateSelection
Number of bits currently supported.
Enabke MinBias triggers for the Offbeam BNB stream.
Enable MinBias triggers for the Calibration stream.
Enable Offbeam drift gate NuMI (for light out-of-time in offbeam gates)
Enable NuMI early warning signal (MIBS$74) to open NuMI gates.
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.
Enable MinBias triggers for the Offbeam NuMI stream.
Enable Offbeam gate for BNB.
Enable Offbeam drift gate BNB (for light out-of-time in offbeam gates)
Enable MinBias triggers for the BNB stream.
Enable Calibration drift gate (for light out-of-time in calibration gates)
Enable Offbeam gate for NuMI.
Enable BNB early-early warning signal ($1D) for light out-of-time in BNB gates.
Enable receiving NuMI early-early warning signal ($AD) for light out-of-time in NuMI gates...
Enable MinBias triggers for the NuMI stream.
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.
enum sbn::bits::triggerLocation : unsigned int
strong

Location or locations generating a trigger.

Enumerator
CryoEast 

A trigger happened in the east cryostat.

CryoWest 

A trigger happened in the west cryostat.

TPCEE 

A trigger happened in the east cryostat, east TPC.

TPCEW 

A trigger happened in the east cryostat, west TPC.

TPCWE 

A trigger happened in the west cryostat, east TPC.

TPCWW 

A trigger happened in the west cryostat, west TPC.

NBits 

Number of bits currently supported.

Definition at line 113 of file BeamBits.h.

113  : unsigned int {
114  CryoEast, ///< A trigger happened in the east cryostat.
115  CryoWest, ///< A trigger happened in the west cryostat.
116  TPCEE, ///< A trigger happened in the east cryostat, east TPC.
117  TPCEW, ///< A trigger happened in the east cryostat, west TPC.
118  TPCWE, ///< A trigger happened in the west cryostat, east TPC.
119  TPCWW, ///< A trigger happened in the west cryostat, west TPC.
120  // ==> add here if more are needed <==
121  NBits ///< Number of bits currently supported.
122  }; // triggerLocation
Number of bits currently supported.
A trigger happened in the east cryostat.
A trigger happened in the east cryostat, west TPC.
A trigger happened in the west cryostat, west TPC.
A trigger happened in the east cryostat, east TPC.
A trigger happened in the west cryostat.
A trigger happened in the west cryostat, east TPC.
enum sbn::bits::triggerSource : unsigned int
strong

Type of beam or beam gate or other trigger source.

Enumerator
Unknown 

Type of beam unknown.

BNB 

Type of beam: BNB.

NuMI 

Type of beam: NuMI.

OffbeamBNB 

Type of Offbeam: BNB.

OffbeamNuMI 

Type of Offbeam: NuMI.

Calib 

Type of source: calibration trigger.

NBits 

Number of bits currently supported.

Definition at line 97 of file BeamBits.h.

97  : unsigned int {
98  Unknown, ///< Type of beam unknown.
99  BNB, ///< Type of beam: BNB.
100  NuMI, ///< Type of beam: NuMI.
101  OffbeamBNB, ///< Type of Offbeam: BNB.
102  OffbeamNuMI, ///< Type of Offbeam: NuMI.
103  Calib, ///< Type of source: calibration trigger.
104  // ==> add here if more are needed <==
105  NBits ///< Number of bits currently supported.
106  }; // triggerSource
Number of bits currently supported.
Type of beam unknown.
Type of source: calibration trigger.
Type of beam: NuMI.
enum sbn::bits::triggerType : unsigned int
strong

Type representing the type(s) of this trigger.

Enumerator
Majority 

A minimum number of close-by PMT pairs above threshold was reached.

MinimumBias 

Data collected at gate opening with no further requirement imposed.

NBits 

Number of bits currently supported.

Definition at line 128 of file BeamBits.h.

128  : unsigned int {
129  Majority, ///< A minimum number of close-by PMT pairs above threshold was reached.
130  MinimumBias, ///< Data collected at gate opening with no further requirement imposed.
131  // ==> add here if more are needed <==
132  NBits ///< Number of bits currently supported.
133  }; // triggerType
Number of bits currently supported.
Data collected at gate opening with no further requirement imposed.
A minimum number of close-by PMT pairs above threshold was reached.
enum sbn::bits::triggerWindowMode : unsigned int
strong

Trigger window mode.

Enumerator
Separated 

Separated, non-overlapping contigous window.

Overlapping 

Overlaping windows.

NBits 

Number of Bits currently supported.

Definition at line 139 of file BeamBits.h.

139  : unsigned int {
140  Separated, ///< Separated, non-overlapping contigous window
141  Overlapping, ///< Overlaping windows
142  //==> add here if more are needed <==
143  NBits ///< Number of Bits currently supported
144  };
Number of bits currently supported.
Separated, non-overlapping contigous window.

Function Documentation

std::string sbn::bits::bitName ( triggerSource  bit)
inline

Returns a mnemonic short name of the beam type.

Todo:
Move into an implementation file once this header in the final location.

Definition at line 267 of file BeamBits.h.

267  {
268 
269  using namespace std::string_literals;
270  switch (bit) {
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;
278  } // switch
279  throw std::runtime_error("sbn::bits::bitName(triggerSource{ "s
280  + std::to_string(value(bit)) + " }): unknown bit"s);
281 } // sbn::bitName()
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
Definition: file_to_url.sh:60
temporary value
std::string sbn::bits::bitName ( triggerLocation  bit)
inline

Returns a mnemonic short name of the trigger location.

Definition at line 285 of file BeamBits.h.

285  {
286 
287  using namespace std::string_literals;
288  switch (bit) {
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;
296  } // switch
297  throw std::runtime_error("sbn::bits::bitName(triggerLocation{ "s
298  + std::to_string(value(bit)) + " }): unknown bit"s);
299 } // sbn::bitName(triggerLocation)
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
Definition: file_to_url.sh:60
temporary value
std::string sbn::bits::bitName ( triggerType  bit)
inline

Returns a mnemonic short name of the trigger type.

Definition at line 302 of file BeamBits.h.

302  {
303 
304  using namespace std::string_literals;
305  switch (bit) {
306  case triggerType::Majority: return "majority"s;
307  case triggerType::MinimumBias: return "minimum bias"s;
308  case triggerType::NBits: return "<invalid>"s;
309  } // switch
310  throw std::runtime_error("sbn::bits::bitName(triggerType{ "s
311  + std::to_string(value(bit)) + " }): unknown bit"s);
312 } // sbn::bitName(triggerType)
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
Definition: file_to_url.sh:60
temporary value
std::string sbn::bits::bitName ( triggerWindowMode  bit)
inline

Returns a mnemonic short name for the trigger window mode.

Definition at line 314 of file BeamBits.h.

314  {
315 
316  using namespace std::string_literals;
317  switch (bit) {
318  case sbn::bits::triggerWindowMode::Separated: return "Separated Window"s;
319  case sbn::bits::triggerWindowMode::Overlapping: return "Overlapping Window"s;
320  case sbn::bits::triggerWindowMode::NBits: return "<invalid>"s;
321  } // switch
322  throw std::runtime_error("sbn::bits::bitName(triggerWindowMode{ "s
323  + std::to_string(value(bit)) + " }): unknown bit"s);
324 } // triggerWindowMode
Number of bits currently supported.
Separated, non-overlapping contigous window.
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
Definition: file_to_url.sh:60
temporary value
std::string sbn::bits::bitName ( gateSelection  bit)
inline

Returns a mnemonic short name for the trigger window mode.

Definition at line 327 of file BeamBits.h.

327  {
328 
329  using namespace std::string_literals;
330  switch (bit) {
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;
352  } // switch
353  throw std::runtime_error("sbn::bits::bitName(gateSelection{ "s
354  + std::to_string(value(bit)) + " }): unknown bit"s);
355 } // sbn::bitName()
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
Definition: file_to_url.sh:60
temporary value
template<typename EnumType >
constexpr bool sbn::bits::hasBitSet ( mask_t< EnumType >  bitMask,
EnumType  bit 
)

Returns whether the specified bit is set in bitMask.

Definition at line 232 of file BeamBits.h.

233  { return bitMask & mask(bit); }
constexpr mask_t< EnumType > mask(EnumType bit, OtherBits...otherBits)
Returns a mask with all specified bits set.
template<typename EnumType >
mask_t<EnumType> sbn::bits::makeMask ( typename mask_t< EnumType >::maskbits_t  bits)
noexcept

Converts a integral type into a mask.

template<typename EnumType , typename... OtherBits>
constexpr mask_t<EnumType> sbn::bits::mask ( EnumType  bit,
OtherBits...  otherBits 
)

Returns a mask with all specified bits set.

template<typename EnumType >
std::string sbn::bits::name ( EnumType  bit)

Returns the name of the specified bit. Delegates to bitName().

Definition at line 238 of file BeamBits.h.

239  { return bitName(bit); }
std::string bitName(triggerSource bit)
Returns a mnemonic short name of the beam type.
Definition: BeamBits.h:267
template<typename EnumType >
std::vector< std::string > sbn::bits::names ( mask_t< EnumType >  mask)

Returns a list of the names of all the bits set in mask. Mask is interpreted as made of only bits of type EnumType.

Definition at line 244 of file BeamBits.h.

244  {
245  static_assert(value(EnumType::NBits) >= 0);
246 
247  using namespace std::string_literals;
248 
249  constexpr std::size_t MaxBits = sizeof(mask) * 8U;
250  constexpr std::size_t NSupportedBits = value(EnumType::NBits);
251 
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)
257  ? "<unsupported ["s + std::to_string(bit) + "]>"s: name(typedBit)
258  );
259  } // for
260  return names;
261 
262 } // sbn::bits::names()
constexpr bool hasBitSet(mask_t< EnumType > bitMask, EnumType bit)
Returns whether the specified bit is set in bitMask.
Definition: BeamBits.h:232
constexpr mask_t< EnumType > mask(EnumType bit, OtherBits...otherBits)
Returns a mask with all specified bits set.
static const std::vector< std::string > names
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
Definition: file_to_url.sh:60
then echo fcl name
temporary value
template<typename EnumType >
constexpr auto sbn::bits::value ( EnumType  bit)

Returns the value of specified bit (conversion like enum to int).

Definition at line 215 of file BeamBits.h.

216  { return static_cast<std::underlying_type_t<EnumType>>(bit); }