MINT2
Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
QuarkContent Class Reference

#include <QuarkContent.h>

Inheritance diagram for QuarkContent:
MINT::PolymorphVector< int >

Public Member Functions

 QuarkContent ()
 
 QuarkContent (const QuarkContent &other)
 
void antiThis ()
 
bool initFromString (const std::string &str)
 
int content (int quarkNumber) const
 
int content (long int quarkNumber) const
 
int content (unsigned int quarkNumber) const
 
int content (char quarkName) const
 
int content (const std::string &quarkName) const
 
char nameFromPosition (int i) const
 
int positionFromName (char c) const
 
void print (std::ostream &os=std::cout) const
 
QuarkContentoperator+= (const QuarkContent &rhs)
 
QuarkContentoperator-= (const QuarkContent &rhs)
 
QuarkContent operator+ (const QuarkContent &rhs) const
 
QuarkContent operator- (const QuarkContent &rhs) const
 
- Public Member Functions inherited from MINT::PolymorphVector< int >
 PolymorphVector ()
 
 PolymorphVector (unsigned int N)
 
 PolymorphVector (unsigned int N, const int &c)
 
 PolymorphVector (const PolymorphVector &other)
 
 PolymorphVector (const typename std::vector< int > &other)
 
virtual ~PolymorphVector ()
 
std::vector< int > & theVector ()
 
const std::vector< int > & theVector () const
 
int & operator[] (unsigned int i)
 
const int & operator[] (unsigned int i) const
 
int & at (unsigned int i)
 
const int & at (unsigned int i) const
 
std::vector< int >::iterator begin ()
 
std::vector< int >::const_iterator begin () const
 
std::vector< int >::iterator end ()
 
std::vector< int >::const_iterator end () const
 
std::vector< int >::iterator find (const int &c)
 
std::vector< int >::const_iterator find (const int &c) const
 
int & front ()
 
const int & front () const
 
int & back ()
 
const int & back () const
 
unsigned int size () const
 
bool empty () const
 
void push_back (const int &c)
 
void pop_back ()
 
void erase (typename std::vector< int >::iterator pos)
 
void erase (typename std::vector< int >::iterator first, typename std::vector< int >::iterator last)
 
PolymorphVector< int > & operator= (const PolymorphVector< int > &other)
 
void clear ()
 
void resize (unsigned int N)
 
void resize (unsigned int N, const int &c)
 
 operator const typename std::vector< int > & () const
 
 operator typename std::vector< int > & ()
 
bool operator== (const MINT::PolymorphVector< int > &v2) const
 
bool operator!= (const MINT::PolymorphVector< int > &v2) const
 
bool operator< (const MINT::PolymorphVector< int > &v2) const
 
bool operator> (const MINT::PolymorphVector< int > &v2) const
 

Static Private Member Functions

static bool initPositions ()
 

Static Private Attributes

static char _names [6] = {'d', 'u', 's', 'c', 'b', 't'}
 
static char _NAMES [6] = {'D', 'U', 'S', 'C', 'B', 'T'}
 
static std::map< char, int > _positions
 

Additional Inherited Members

- Protected Attributes inherited from MINT::PolymorphVector< int >
std::vector< int > _vec
 

Detailed Description

Definition at line 9 of file QuarkContent.h.

Constructor & Destructor Documentation

◆ QuarkContent() [1/2]

QuarkContent::QuarkContent ( )

Definition at line 11 of file QuarkContent.cpp.

13 {
14  initPositions();
15 }
static bool initPositions()

◆ QuarkContent() [2/2]

QuarkContent::QuarkContent ( const QuarkContent other)

Definition at line 17 of file QuarkContent.cpp.

Member Function Documentation

◆ antiThis()

void QuarkContent::antiThis ( )

Definition at line 29 of file QuarkContent.cpp.

29  {
30  for(unsigned int i=0; i < this->size(); i++){
31  (*this)[i] *= -1;
32  }
33 }
unsigned int size() const

◆ content() [1/5]

int QuarkContent::content ( int  quarkNumber) const

Definition at line 69 of file QuarkContent.cpp.

69  {
70  if(quarkNumber < 0) return 0;
71  return content( (unsigned int) quarkNumber);
72 }
int content(int quarkNumber) const

◆ content() [2/5]

int QuarkContent::content ( long int  quarkNumber) const

Definition at line 66 of file QuarkContent.cpp.

66  {
67  return content( (int) quarkNumber);
68 }
int content(int quarkNumber) const

◆ content() [3/5]

int QuarkContent::content ( unsigned int  quarkNumber) const

Definition at line 73 of file QuarkContent.cpp.

73  {
74  if(quarkNumber >= this->size()) return 0;
75  return (*this)[quarkNumber];
76 }
unsigned int size() const

◆ content() [4/5]

int QuarkContent::content ( char  quarkName) const

Definition at line 83 of file QuarkContent.cpp.

83  {
84  return content(positionFromName(quarkName));
85 }
int content(int quarkNumber) const
int positionFromName(char c) const

◆ content() [5/5]

int QuarkContent::content ( const std::string &  quarkName) const

Definition at line 78 of file QuarkContent.cpp.

78  {
79  if(quarkName.empty()) return 0;
80  return content(quarkName[0]);
81 }
int content(int quarkNumber) const

◆ initFromString()

bool QuarkContent::initFromString ( const std::string &  str)

Definition at line 35 of file QuarkContent.cpp.

35  {
36  for(unsigned int i=0; i < this->size(); i++){
37  (*this)[i]=0;
38  }
39  unsigned int pos =str.find("non-qQ");
40  if(pos < str.size())return true;
41 
42  std::string localQ = str;
43  pos = localQ.find("sqrt");
44  if(pos < localQ.size()){
45  localQ.replace(pos, 4, "");
46  }
47  //cout << "str : " << str << " localQ " << localQ << endl;
48 
49  for(unsigned int i=0; i < localQ.size(); i++){
50  if('d' == localQ[i]) (*this)[0]++;
51  if('D' == localQ[i]) (*this)[0]--;
52  if('u' == localQ[i]) (*this)[1]++;
53  if('U' == localQ[i]) (*this)[1]--;
54  if('s' == localQ[i]) (*this)[2]++;
55  if('S' == localQ[i]) (*this)[2]--;
56  if('c' == localQ[i]) (*this)[3]++;
57  if('C' == localQ[i]) (*this)[3]--;
58  if('b' == localQ[i]) (*this)[4]++;
59  if('B' == localQ[i]) (*this)[4]--;
60  if('t' == localQ[i]) (*this)[5]++;
61  if('T' == localQ[i]) (*this)[5]--;
62  }
63  return true;
64 }
unsigned int size() const

◆ initPositions()

bool QuarkContent::initPositions ( )
staticprivate

Definition at line 21 of file QuarkContent.cpp.

21  {
22  if(_positions.empty()){
23  for(int i=0; i < 6; i++) _positions[_names[i]]=i;
24  for(int i=0; i < 6; i++) _positions[_NAMES[i]]=i;
25  }
26  return true;
27 }
static char _NAMES[6]
Definition: QuarkContent.h:11
static char _names[6]
Definition: QuarkContent.h:10
static std::map< char, int > _positions
Definition: QuarkContent.h:12

◆ nameFromPosition()

char QuarkContent::nameFromPosition ( int  i) const

Definition at line 86 of file QuarkContent.cpp.

86  {
87  if(i < 0 || i >=6) return 'X';
88  else return _names[i];
89 }
static char _names[6]
Definition: QuarkContent.h:10

◆ operator+()

QuarkContent QuarkContent::operator+ ( const QuarkContent rhs) const

Definition at line 120 of file QuarkContent.cpp.

120  {
121  QuarkContent returnVal(*this);
122  returnVal += rhs;
123  return returnVal;
124 }

◆ operator+=()

QuarkContent & QuarkContent::operator+= ( const QuarkContent rhs)

Definition at line 103 of file QuarkContent.cpp.

103  {
104  unsigned int max = this->size();
105  if(rhs.size() < max) max = rhs.size();
106  for(unsigned int i=0; i < max; i++){
107  (*this)[i] += rhs[i];
108  }
109  return *this;
110 }
unsigned int size() const

◆ operator-()

QuarkContent QuarkContent::operator- ( const QuarkContent rhs) const

Definition at line 125 of file QuarkContent.cpp.

125  {
126  QuarkContent returnVal(*this);
127  returnVal -= rhs;
128  return returnVal;
129 }

◆ operator-=()

QuarkContent & QuarkContent::operator-= ( const QuarkContent rhs)

Definition at line 111 of file QuarkContent.cpp.

111  {
112  unsigned int max = this->size();
113  if(rhs.size() < max) max = rhs.size();
114  for(unsigned int i=0; i < max; i++){
115  (*this)[i] -= rhs[i];
116  }
117  return *this;
118 }
unsigned int size() const

◆ positionFromName()

int QuarkContent::positionFromName ( char  c) const

Definition at line 90 of file QuarkContent.cpp.

90  {
91  map<char, int>::const_iterator it = _positions.find(c);
92  if(_positions.end() == it) return -9999;
93  else return it->second;
94 }
static std::map< char, int > _positions
Definition: QuarkContent.h:12

◆ print()

void QuarkContent::print ( std::ostream &  os = std::cout) const

Definition at line 96 of file QuarkContent.cpp.

96  {
97  for(unsigned int i=0; i < this->size(); i++){
98  os << "(" << nameFromPosition(i) << ":" << (*this)[i] << ")";
99  if(i + 1< this->size()) os << " ";
100  }
101 }
char nameFromPosition(int i) const
unsigned int size() const

Member Data Documentation

◆ _names

char QuarkContent::_names = {'d', 'u', 's', 'c', 'b', 't'}
staticprivate

Definition at line 10 of file QuarkContent.h.

◆ _NAMES

char QuarkContent::_NAMES = {'D', 'U', 'S', 'C', 'B', 'T'}
staticprivate

Definition at line 11 of file QuarkContent.h.

◆ _positions

map< char, int > QuarkContent::_positions
staticprivate

Definition at line 12 of file QuarkContent.h.


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