Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:51:43

0001 #ifndef QUARK_FLAVOR_H
0002 #define QUARK_FLAVOR_H
0003 
0004 /**
0005  *
0006  * @file QuarkFlavor.h
0007  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0008  * @date 22 July 2014
0009  * @version 1.0
0010  */
0011 
0012 #include <string>
0013 
0014 namespace PARTONS {
0015 
0016 /**
0017  * @class QuarkFlavor
0018  *
0019  * @brief Definition of enumeration values for quark flavors.
0020  *
0021  * This class defines a set of enumeration values that are used to distinguish between quark flavors. In addition, a declared object of this class is always associated to one quark flavor type (see QuarkFlavor::m_type), so member functions can act on it. E.g.
0022  \code{.cpp}
0023  //this is single enum variable - nothing to play with
0024  QuarkFlavor::Type enum_variable = QuarkFlavor::UP;
0025 
0026  //this is declared object
0027  QuarkFlavor enum_object;
0028 
0029  //let us assign some type (default is QuarkFlavor::UNDEFINED)
0030  enum_object.setType(enum_variable);
0031 
0032  //with objects you can use available functions, e.g. you can represent enumeration type by a corresponding string
0033  std::string enum_string_1 = enum_object.toString();
0034 
0035  //you can achieve some basic operations without the explicit declaration of objects by using the assignment constructor
0036  std::string enum_string_2 = QuarkFlavor(QuarkFlavor::DOWN).toString();
0037 
0038  Partons::getInstance()->getLoggerManager()->info("example", __func__, ElemUtils::Formatter() << "Quark flavor is: " << enum_string_1);
0039  Partons::getInstance()->getLoggerManager()->info("example", __func__, ElemUtils::Formatter() << "Quark flavor is: " << enum_string_2);
0040  \endcode
0041  which gives via Logger:
0042  \code
0043  20-05-2017 12:09:19 [INFO] (example::main) Quark flavor is: UP
0044  20-05-2017 12:09:19 [INFO] (example::main) Quark flavor is: DOWN
0045  \endcode
0046  */
0047 class QuarkFlavor {
0048 
0049 public:
0050 
0051     /**
0052      * Definition of enumerate values corresponding to quark flavors.
0053      */
0054     enum Type {
0055         UNDEFINED = 0,      //!< Undefined type.
0056         UP = 1,      //!< Quark flavor up.
0057         DOWN = 2,    //!< Quark flavor down.
0058         STRANGE = 3, //!< Quark flavor strange.
0059         CHARM = 4,   //!< Quark flavor charm.
0060         BOTTOM = 5,  //!< Quark flavor bottom.
0061         TOP = 6     //!< Quark flavor top.
0062     };
0063 
0064     /**
0065      * Default constructor.
0066      */
0067     QuarkFlavor();
0068 
0069     /**
0070      * Copy constructor.
0071      * @param other Object to be copied.
0072      */
0073     QuarkFlavor(const QuarkFlavor &other);
0074 
0075     /**
0076      * Assignment constructor.
0077      * @param type Type to be assigned.
0078      */
0079     QuarkFlavor(Type type);
0080 
0081     /**
0082      * Destructor.
0083      */
0084     virtual ~QuarkFlavor();
0085 
0086     /**
0087      * Automatic cast to enum.
0088      */
0089     operator Type() const;
0090 
0091     /**
0092      * Get string representation of type being assigned to a declared object of this class.
0093      * @return String representation of assigned type, like "UP" for QuarkFlavor::UP.
0094      */
0095     std::string toString() const;
0096 
0097     /**
0098      * Get short name representation of type being assigned to a declared object of this class.
0099      * @return Short string representation of assigned type, like "u" for QuarkFlavor::UP.
0100      */
0101     std::string getShortName();
0102 
0103     /**
0104      * Try to match quark flavor from given string.
0105      * @param quarkFlavorStr String to be matched.
0106      * @return Matched type or QuarkFlavor::UNDEFINED if unable to match.
0107      */
0108     static QuarkFlavor::Type fromString(const std::string & quarkFlavorStr);
0109 
0110     //********************************************************
0111     //*** SETTERS AND GETTERS ********************************
0112     //********************************************************
0113 
0114     /**
0115      * Get type being assigned to a declared object of this class.
0116      */
0117     QuarkFlavor::Type getType() const;
0118 
0119     /**
0120      * Assign type to a declared object of this class.
0121      */
0122     void setType(Type type);
0123 
0124 private:
0125 
0126     /**
0127      * Type associated to a declared object of this class.
0128      */
0129     QuarkFlavor::Type m_type;
0130 };
0131 
0132 } /* namespace PARTONS */
0133 
0134 #endif /* QUARK_FLAVOR_H */