All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
icarus::WeakCurrentType Class Reference

Represents a type of weak current. More...

#include <WeakCurrentType.h>

Public Types

enum  CurrentType { CC, NC, any }
 Type of weak current. More...
 

Public Member Functions

constexpr WeakCurrentType ()=default
 Default constructor: matches any current type. More...
 
constexpr WeakCurrentType (CurrentType type)
 Constructor: assigns the specified current type. More...
 
 WeakCurrentType (std::string const &spec)
 
 operator int () const
 
String operations
std::string name () const
 
std::string shortName () const
 
 operator std::string () const
 Converts to the name() of the current. More...
 
Comparisons
constexpr bool operator== (WeakCurrentType const &other) const
 Returns whether this current type is the same as the other. More...
 
constexpr bool operator!= (WeakCurrentType const &other) const
 Returns whether this current type is different than the other. More...
 

Static Public Member Functions

static CurrentType parse (std::string const &spec)
 Converts a string into a WeakCurrentType. More...
 

Static Private Member Functions

static std::string to_upper (std::string const &s)
 Returns a upper-case copy of s. More...
 

Private Attributes

CurrentType fType = any
 Type of current stored. More...
 

Detailed Description

Represents a type of weak current.

This type can be initialised with a string (see parse()) or a mnemonic value (CurrentType).

Example of usage:

icarus::WeakCurrentType const current { "neutral" };
std::cout << "Current type: " << std::string(current) << std::endl;
if (current == icarus::NeutralCurrentType) {
std::cout << "Well, yeah." << std::endl;
}
// use WeakCurrentType::CurrentType in switch statements:
std::string boson;
switch (current) {
case WeakCurrentType::CC: boson = "W"; break;
case WeakCurrentType::NC: boson = "Z"; break;
case WeakCurrentType::any: boson = "V"; break;
} // switch

Definition at line 54 of file WeakCurrentType.h.

Member Enumeration Documentation

Type of weak current.

Enumerator
CC 

Charged current.

NC 

Neutral current.

any 

Any interaction.

Definition at line 59 of file WeakCurrentType.h.

59  {
60  CC, ///< Charged current.
61  NC, ///< Neutral current.
62  any ///< Any interaction.
63  }; // enum CurrentType

Constructor & Destructor Documentation

constexpr icarus::WeakCurrentType::WeakCurrentType ( )
default

Default constructor: matches any current type.

constexpr icarus::WeakCurrentType::WeakCurrentType ( CurrentType  type)
inline

Constructor: assigns the specified current type.

Definition at line 72 of file WeakCurrentType.h.

72 : fType(type) {}
CurrentType fType
Type of current stored.
icarus::WeakCurrentType::WeakCurrentType ( std::string const &  spec)
inlineexplicit

Constructor: assigns the value interpreting the specification spec.

See Also
WeakCurrentType::parse()

Definition at line 76 of file WeakCurrentType.h.

77  : WeakCurrentType(parse(spec)) {}
constexpr WeakCurrentType()=default
Default constructor: matches any current type.
static CurrentType parse(std::string const &spec)
Converts a string into a WeakCurrentType.

Member Function Documentation

std::string icarus::WeakCurrentType::name ( ) const

Returns a string with the name of the current ("charged", "neutral", "any").

Definition at line 34 of file WeakCurrentType.cxx.

34  {
35 
36  switch (fType) {
37  case CC: return "charged";
38  case NC: return "neutral";
39  case any: return "any";
40  } // switch
41  throw std::logic_error("icarus::WeakCurrentType::name()");
42 } // icarus::WeakCurrentType::name()
CurrentType fType
Type of current stored.
icarus::WeakCurrentType::operator int ( ) const
inline

Definition at line 119 of file WeakCurrentType.h.

119 { return static_cast<int>(fType); }
CurrentType fType
Type of current stored.
icarus::WeakCurrentType::operator std::string ( ) const
inline

Converts to the name() of the current.

Definition at line 96 of file WeakCurrentType.h.

96 { return name(); }
std::string name() const
constexpr bool icarus::WeakCurrentType::operator!= ( WeakCurrentType const &  other) const
inline

Returns whether this current type is different than the other.

Definition at line 111 of file WeakCurrentType.h.

112  { return fType != other.fType; }
CurrentType fType
Type of current stored.
constexpr bool icarus::WeakCurrentType::operator== ( WeakCurrentType const &  other) const
inline

Returns whether this current type is the same as the other.

Definition at line 107 of file WeakCurrentType.h.

108  { return fType == other.fType; }
CurrentType fType
Type of current stored.
auto icarus::WeakCurrentType::parse ( std::string const &  spec)
static

Converts a string into a WeakCurrentType.

Parameters
specthe specification string to be converted
Exceptions
cet::exception(category "WeakCurrentType") if spec is not supported

The case of spec is irrelevant. Accepted values include the shortened name ("CC"; see shortName()), and the full name ("charged"; see name()). Also the empty string is converted to a CurrentType of any.

Definition at line 72 of file WeakCurrentType.cxx.

72  {
73 
74  std::string const SPEC = to_upper(spec);
75 
76  if (anyOf(SPEC, { "CHARGED", "CC" })) return CC;
77  if (anyOf(SPEC, { "NEUTRAL", "NC" })) return NC;
78  if (anyOf(SPEC, { "", "ANY" })) return any;
79 
80  throw cet::exception("WeakCurrentType")
81  << "Invalid weak current specification: '" << spec << "'\n";
82 
83 } // icarus::WeakCurrentType::parse()
static std::string to_upper(std::string const &s)
Returns a upper-case copy of s.
std::string icarus::WeakCurrentType::shortName ( ) const

Returns a string with the short name of the current ("CC", "NC", "any").

Definition at line 46 of file WeakCurrentType.cxx.

46  {
47 
48  switch (fType) {
49  case CC: return "CC";
50  case NC: return "NC";
51  case any: return "any";
52  } // switch
53  throw std::logic_error("icarus::WeakCurrentType::shortName()");
54 
55 } // icarus::WeakCurrentType::shortName()
CurrentType fType
Type of current stored.
std::string icarus::WeakCurrentType::to_upper ( std::string const &  s)
staticprivate

Returns a upper-case copy of s.

Definition at line 59 of file WeakCurrentType.cxx.

59  {
60 
61  std::string S;
62  S.reserve(s.size());
63 
64  auto char_toupper = [](unsigned char c){ return std::toupper(c); };
65  std::transform(s.begin(), s.end(), std::back_inserter(S), char_toupper);
66 
67  return S;
68 } // icarus::WeakCurrentType::to_upper()
see a below echo S(symbol in a section other than those above)
static constexpr Sample_t transform(Sample_t sample)
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60

Member Data Documentation

CurrentType icarus::WeakCurrentType::fType = any
private

Type of current stored.

Definition at line 138 of file WeakCurrentType.h.


The documentation for this class was generated from the following files: