GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parity.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef ROOT_TString
24 #include <TString.h>
25 #endif
26 
27 #ifndef Gw_Parity
28 #include "Parity.h"
29 #endif
30 
31 using namespace Gw;
32 
34 
36  : QNumber(), InfoData()
37 {
38  fParity = kPlus;
39 }
40 
41 
43 {
44 }
45 
46 void Parity::Set(const char *s)
47 {
48  TString st = s;
49  switch( WhatIs(s) ){
50  case kKnown:
51  if ( st.Contains('-') )
52  fParity = kMinus;
53  else
54  fParity = kPlus;
55  SetInfo(kKnown);
56  break;
57  case kUnknown:
59  break;
60  case kAbout:
61  if ( st.Contains('-') )
62  fParity = kMinus;
63  else
64  fParity = kPlus;
65  SetInfo(kAbout);
66  break;
67  case kTentative:
68  if ( st.Contains('-') )
69  fParity = kMinus;
70  else
71  fParity = kPlus;
73  break;
74  case kTheo:
75  if ( st.Contains('-') )
76  fParity = kMinus;
77  else
78  fParity = kPlus;
79  SetInfo(kTheo);
80  break;
81  default:
83  break;
84  }
85 }
86 
88 {
89  fParity *= p.fParity;
90  return *this;
91 }
92 
93 std::ostream & operator << (std::ostream &out, const Parity &p)
94 {
95  string sep1, sep2;
96 
97  if ( p.IsData(InfoData::kUnknown) ) {
98  out << "?" ; return out;
99  }
100  sep1 = sep2 = "";
101  if ( p.IsData(InfoData::kTentative) )
102  { sep1 = '('; sep2 = ')'; }
103  if ( p.IsData(InfoData::kTheo) )
104  { sep1 = '['; sep2 = ']'; }
105  if ( p.IsData(InfoData::kAbout) )
106  { sep1 = '~'; sep2 = ""; }
107 
108  if ( p.IsParity(Parity::kPlus) ) {
109  out << sep1 << "+" << sep2;
110  return out;
111  }
112  else {
113  out << sep1 << "-" << sep2;
114  return out;
115  }
116 }
117 
118 
ClassImp(Parity)
static EData WhatIs(const char *)
It deduces from a string the kind of data.
Definition: InfoData.cpp:45
virtual bool IsData(UShort_t) const
to get some information about this data
Definition: InfoData.h:82
Base class for a quantum number.
Definition: QNumber.h:43
This class discribes a specific quantum number: the parity.
Definition: Parity.h:46
bool IsParity(Parity::EParity) const
Definition: Parity.h:78
std::ostream & operator<<(std::ostream &out, const Parity &p)
to write a parity in a stream
Definition: Parity.cpp:93
void Set(Parity::EParity)
Definition: Parity.h:77
Base class to get/set some flag informations concerning any data.
Definition: InfoData.h:46
header file for the Parity quantum number
virtual void SetInfo(InfoData::EData)
to set some information about this data
Definition: InfoData.h:83
Parity & operator*=(Parity &p)
overload operator*
Definition: Parity.cpp:87
virtual ~Parity()
Definition: Parity.cpp:42