Commit 33a7f8c3 authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

graphical interaction with Level and NuclearLevel now working

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@209 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent d4cc9ae0
......@@ -20,6 +20,8 @@
/** \file Data.cpp root dictionary compiled in libGWPHYSICS.so */
#ifndef GW_DATA_H
#include "Data.h"
#endif
......@@ -31,3 +33,8 @@ using namespace Gw;
#else
templateClassImp(Data);
#endif
......@@ -33,10 +33,18 @@
#ifndef GW_DATA_H
#define GW_DATA_H
#ifndef ROOT_TString
#include <TString.h>
#endif
#include <iostream>
#include <sstream>
#ifndef GW_INFODATA_H
#include "InfoData.h"
#endif
namespace Gw {
/**
......@@ -63,6 +71,45 @@ public:
//! set the value, can be overloaded
virtual void Set(Data_T data) { fValue = data; }
//! set the value, can be overloaded
virtual void Set(const char *s)
{
std::istringstream input; input.clear(); TString st = s;
switch( WhatIs(s) ){
case kKnown:
input.str(s); input >> fValue;
if ( input.fail() ) SetInfo(kUnknown);
else SetInfo(kKnown);
break;
case kUnknown:
SetInfo(kUnknown);
break;
case kAbout:
st.ReplaceAll('~',' ');
input.str(st.Data()); input >> fValue;
if ( input.fail() ) SetInfo(kUnknown);
else SetInfo(kAbout);
break;
case kTentative:
st.ReplaceAll('(',' ');
st.ReplaceAll(')',' ');
input.str(st.Data()); input >> fValue;
if ( input.fail() ) SetInfo(kUnknown);
else SetInfo(kTentative);
break;
case kTheo:
st.ReplaceAll('[',' ');
st.ReplaceAll(']',' ');
input.str(st.Data()); input >> fValue;
if ( input.fail() ) SetInfo(kUnknown);
else SetInfo(kTheo);
break;
default:
SetInfo(kUnknown);
break;
}
}
//! get the value, cannot be overloaded
Data_T GetValue() const { return fValue; }
//! set the value, cannot be overloaded
......
......@@ -44,14 +44,30 @@ InfoData::~InfoData()
InfoData::EData InfoData::WhatIs(const char *s)
{
TString st = s;
TString st = s; Short_t nb, nb_unkown, nb_theo_left, nb_theo_right, nb_tenta_left, nb_tenta_right, nb_about;
Short_t nb_unkown, nb_tho_left, nb_tho_right, nb_tenta_left, nb_tenta_right, nb_about;
// reads the string and counts the specfics characters
nb = nb_unkown = nb_theo_left = nb_theo_right = nb_tenta_left = nb_tenta_right = nb_about = 0;
Int_t end = st.Length();
for( Int_t i = 0 ; i < end; i++ ){
if ( st[i] == '?' ) { nb_unkown++; nb++; }
if ( st[i] == '(' ) { nb_tenta_left++; nb++;} ; if ( st[i] == ')' ) { nb_tenta_right++; nb++;}
if ( st[i] == '[' ) { nb_theo_left++; nb++; } ; if ( st[i] == ']' ) { nb_theo_right++; nb++; }
if ( st[i] == '~' ) { nb_about++; nb++; }
}
// set the informations
if ( nb > 2 ) return kUnknown;
if ( nb == 0 ) return kKnown;
nb_unkown = nb_tho_left = nb_tho_right = nb_tenta_left = nb_tenta_right = nb_about = 0;
return kKnown;
if ( nb == 1 ) {
if ( nb_about == 1 ) return kAbout;
else return kUnknown;
}
else { // nb = 2
if ( nb_tenta_left == 1 && nb_tenta_right == 1 ) return kTentative;
if ( nb_theo_left == 1 && nb_theo_right == 1 ) return kTheo;
}
return kUnknown;
}
......@@ -60,7 +60,10 @@ public:
InfoData(const InfoData &);
virtual ~InfoData();
//! It deduces fro a string the kind of data
//! It deduces from a string the kind of data
/*!
*/
static EData WhatIs(const char *);
//! to get some information about this data
......@@ -68,6 +71,9 @@ public:
//! to set some information about this data
virtual void SetInfo(InfoData::EData);
//! to set some information about this data
virtual void Set(const char *st) { fInfo = WhatIs(st) ; }
//! rootcint dictionary
ClassDef(InfoData,1); // InfoData base class
......
......@@ -36,8 +36,6 @@
#include "Data.h"
#endif
// std includes
#include <iostream>
namespace Gw {
......@@ -66,6 +64,45 @@ public:
//! set the measure and its error (default err=0)
virtual void Set(Data_T data) { Data<Data_T>::fValue = data; fError = 0; }
virtual void Set(Data_T d, Data_T derr) { Data<Data_T>::fValue = d; fError = derr; }
//! set the value, can be overloaded
virtual void Set(const char *s)
{
std::istringstream input; input.clear(); TString st = s;
switch( InfoData::WhatIs(s) ){
case InfoData::kKnown:
input.str(s); input >> Data<Data_T>::fValue >> fError;
if ( input.fail() ) InfoData::SetInfo(InfoData::kUnknown);
else InfoData::SetInfo(InfoData::kKnown);
break;
case InfoData::kUnknown:
InfoData::SetInfo(InfoData::kUnknown);
break;
case InfoData::kAbout:
st.ReplaceAll('~',' ');
input.str(st.Data()); input >> Data<Data_T>::fValue >> fError;
if ( input.fail() ) InfoData::SetInfo(InfoData::kUnknown);
else InfoData::SetInfo(InfoData::kAbout);
break;
case InfoData::kTentative:
st.ReplaceAll('(',' ');
st.ReplaceAll(')',' ');
input.str(st.Data()); input >> Data<Data_T>::fValue >> fError;
if ( input.fail() ) InfoData::SetInfo(InfoData::kUnknown);
else InfoData::SetInfo(InfoData::kTentative);
break;
case InfoData::kTheo:
st.ReplaceAll('[',' ');
st.ReplaceAll(']',' ');
input.str(st.Data()); input >> Data<Data_T>::fValue >> fError;
if ( input.fail() ) InfoData::SetInfo(InfoData::kUnknown);
else InfoData::SetInfo(InfoData::kTheo);
break;
default:
InfoData::SetInfo(InfoData::kUnknown);
break;
}
}
//! return the error on the measured value
virtual Data_T GetError() const { return fError; }
......
......@@ -43,7 +43,7 @@ NuclearLevel::~NuclearLevel()
void NuclearLevel::SetLabels(const char *l0, const char *l1, const char *l2, const char *l3)
{
Level::SetLabels(l0,l1,l2,l3);
fSpin.Set(l0); /* fParity.Set(l1); */ fT.Set(l2); fEnergy.Set(l3); Level::SetLabels(l0,l1,l2,l3);
}
void NuclearLevel::ls(Option_t* o) const
......
......@@ -62,12 +62,12 @@ the second one the parity, the third one the level lifetime (for isomers) and la
class NuclearLevel : public Level {
protected:
BaseNucleus fNucleus; // to which nucleus this level belongs
BaseNucleus fNucleus; // to which nucleus this level belongs
Measure<Float_t> fEnergy; // energy and its error
Measure<Float_t> fT; // half-life of this level
Parity fParity; // parity of this level
Spin fSpin; // spin of this level
Measure<Float_t> fT; // half-life of this level
Parity fParity; // parity of this level
Spin fSpin; // spin of this level
public:
NuclearLevel();
......@@ -78,9 +78,11 @@ public:
//! to get the spin and modify it if it is needed
Spin & GetSpin() { return fSpin ; }
//! get the parity and modify it if it is needed
Parity & GetParity() { return fParity; }
// to get the energy and modify it if it is needed
//! to get the energy and modify it if it is needed
Measure<Float_t> & GetE() { return fEnergy; }
Measure<Float_t> & GetEnergy() { return fEnergy; }
......
......@@ -20,6 +20,10 @@
/** \file Parity.cpp compiled in libGWPHYSICS.so */
#ifndef ROOT_TString
#include <TString.h>
#endif
#ifndef GW_PARITY_H
#include "Parity.h"
#endif
......@@ -39,6 +43,47 @@ Parity::~Parity()
{
}
void Parity::Set(const char *s)
{
TString st = s;
switch( WhatIs(s) ){
case kKnown:
if ( st.Contains('-') )
fParity = kMinus;
else
fParity = kPlus;
SetInfo(kKnown);
break;
case kUnknown:
SetInfo(kUnknown);
break;
case kAbout:
if ( st.Contains('-') )
fParity = kMinus;
else
fParity = kPlus;
SetInfo(kAbout);
break;
case kTentative:
if ( st.Contains('-') )
fParity = kMinus;
else
fParity = kPlus;
SetInfo(kTentative);
break;
case kTheo:
if ( st.Contains('-') )
fParity = kMinus;
else
fParity = kPlus;
SetInfo(kTheo);
break;
default:
SetInfo(kUnknown);
break;
}
}
ostream & Gw::operator << (ostream &out, const Parity &p)
{
string sep1, sep2;
......
......@@ -62,6 +62,9 @@ public:
void Set(Parity::EParity);
bool IsParity(Parity::EParity);
//! set the value, can be overloaded
virtual void Set(const char *s) ;
//! to write a parity in a stream
friend ostream & operator << (ostream &, const Parity &);
......
......@@ -39,7 +39,7 @@ quantum number is a good quantum number. This base class defines the basic types
class QNumber
{
public:
/*! label type for any possible quantum number */
//! label type for any possible quantum number
enum EQtype{ kParity = 0, kSpin = 1, kK = 2, kSignature = 3, kSimplex = 4};
private:
......
......@@ -20,6 +20,13 @@
/** \file Spin.cpp compiled in libGWPHYSICS.so */
#ifndef ROOT_TString
#include <TString.h>
#endif
#include <iostream>
#include <sstream>
#ifndef GW_SPIN_H
#include "Spin.h"
#endif
......@@ -39,6 +46,63 @@ Spin::~Spin()
{
}
void Spin::Set(const char *s)
{
std::istringstream input; input.clear(); TString st = s;
switch( WhatIs(s) ){
case kKnown:
if ( st.Contains('/') ) { // not an integer
st.ReplaceAll('/',' '); input.str(st.Data()); input >> fN >> fD;
}
else { input.str(st.Data()); input >> fN; fD = 1; }
if ( input.fail() )
SetInfo(kUnknown);
else
SetInfo(kKnown);
break;
case kUnknown:
SetInfo(kUnknown);
break;
case kAbout:
st.ReplaceAll('~',' ');
if ( st.Contains('/') ) { // not an integer
st.ReplaceAll('/',' '); input.str(st.Data()); input >> fN >> fD;
}
else { input.str(st.Data()); input >> fN; fD = 1; }
if ( input.fail() )
SetInfo(kUnknown);
else
SetInfo(kAbout);
break;
case kTentative:
st.ReplaceAll('(',' ');
st.ReplaceAll(')',' ');
if ( st.Contains('/') ) { // not an integer
st.ReplaceAll('/',' '); input.str(st.Data()); input >> fN >> fD;
}
else { input.str(st.Data()); input >> fN; fD = 1; }
if ( input.fail() )
SetInfo(kUnknown);
else
SetInfo(kTentative);
break;
case kTheo:
st.ReplaceAll('[',' ');
st.ReplaceAll(']',' ');
if ( st.Contains('/') ) { // not an integer
st.ReplaceAll('/',' '); input.str(st.Data()); input >> fN >> fD;
}
else { input.str(st.Data()); input >> fN; fD = 1; }
if ( input.fail() )
SetInfo(kUnknown);
else
SetInfo(kTheo);
break;
default:
SetInfo(kUnknown);
break;
}
}
/*!
\fn Spin::Set(Int_t n, Int_t d = 1)
......
......@@ -53,10 +53,13 @@ public:
Spin(const Spin &spin): QNumber(spin), InfoData(spin) { fN = spin.fN; fD = spin.fD; }
virtual ~Spin();
// setters and getters
//! setters and getters
void Set(Int_t n, Int_t d = 1);
Float_t Get() const;
//! to set some information about this data
virtual void Set(const char *s) ;
//! to write a Spin in a stream
friend std::ostream & operator << (std::ostream &, Spin);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment