Skip to content
Snippets Groups Projects
DataUtils.hh 2.71 KiB
Newer Older
#ifndef _DataUtils_H
#define _DataUtils_H

#include <boost/shared_ptr.hpp>
#include "qft++/topincludes/relativistic-quantum-mechanics.hh"

struct jpcRes
{
  Spin J;
  int P;
  int C;
  jpcRes(Spin j=0, int p=1, int c=1){
    J=j;
    P=p;
    C=c;
  }
Bertram Kopf's avatar
Bertram Kopf committed
  jpcRes(boost::shared_ptr<const jpcRes> theJPC){
    J=theJPC->J;
    P=theJPC->P;
    C=theJPC->C;
  }

  virtual bool operator==(const jpcRes& compare) const{
    bool result=false;
    if ( fabs(J-compare.J)<1e-8 && P==compare.P && C==compare.C) result=true;
    return result;
  }

Bertram Kopf's avatar
Bertram Kopf committed

  virtual bool operator<(const jpcRes& compare){
    if ( J < compare.J) return true;
    else if ( P < compare.P) return true;
    else if ( C < compare.C) return true;
    return false; 
  }

Bertram Kopf's avatar
Bertram Kopf committed
  virtual void print(std::ostream& os) const{
    os <<"J=" << J << "\tP=" << P << "\tC=" << C;   
  }
Bertram Kopf's avatar
Bertram Kopf committed

struct JPCLS : public jpcRes{
Bertram Kopf's avatar
Bertram Kopf committed
  JPCLS(boost::shared_ptr<const jpcRes> theJPC, const Spin& theL, const Spin& theS): jpcRes(theJPC){
    L=theL;
    S=theS;
Bertram Kopf's avatar
Bertram Kopf committed
  JPCLS(boost::shared_ptr<const JPCLS> theJPCLS): jpcRes(theJPCLS->J, theJPCLS->P, theJPCLS->C){
    L=theJPCLS->L;
    S=theJPCLS->S;
  }

  virtual bool operator==(const jpcRes& compare) const{
    return jpcRes::operator==(compare);
  }

  virtual bool operator==(const JPCLS& compare) const{
    bool result=false;
    if ( fabs(J-compare.J)<1e-8 && P==compare.P && C==compare.C && fabs(L-compare.L)<1e-8 && fabs(S-compare.S)<1e-8 ) result=true;
    return result;
  }
  
  virtual void print(std::ostream& os) const{
    jpcRes::print(os);
    os <<"\tL=" << L << "\tS=" << S;   
Bertram Kopf's avatar
Bertram Kopf committed
struct JPCSM : public jpcRes{
Bertram Kopf's avatar
Bertram Kopf committed
  JPCSM(boost::shared_ptr<const jpcRes> theJPC, const Spin& theS, const Spin& theM): jpcRes(theJPC){
Bertram Kopf's avatar
Bertram Kopf committed
  virtual bool operator==(const jpcRes& compare) const{
    return jpcRes::operator==(compare);
  }

  virtual bool operator==(const JPCSM& compare) const{
    bool result=jpcRes::operator==(compare);;
    if ( fabs(S-compare.S)>1e-8 || fabs(M-compare.M)>1e-8 ) result=false;
    return result;
  }

  void print(std::ostream& os) const{
Bertram Kopf's avatar
Bertram Kopf committed
    jpcRes::print(os);
    os <<"\tS=" << S << "\tM=" << M
       << std::endl;   
  }
Bertram Kopf's avatar
Bertram Kopf committed
struct JPCLSM : public JPCLS{
  boost::shared_ptr<const jpcRes> jpc;
Bertram Kopf's avatar
Bertram Kopf committed
  Spin M;
Bertram Kopf's avatar
Bertram Kopf committed

  JPCLSM(boost::shared_ptr<const JPCLS> theJPCLS, const Spin theM, const double theClebschG) : JPCLS(theJPCLS){
    M=theM;
Bertram Kopf's avatar
Bertram Kopf committed
  virtual bool operator==(const jpcRes& compare) const{
    return jpcRes::operator==(compare);
  }

  virtual void print(std::ostream& os) const{
    JPCLS::print(os);
    os <<"\tM=" << M 
       <<"\tClebschGordan=" << ClebschG