MINT2
FitComplex.h
Go to the documentation of this file.
1 #ifndef FIT_COMPLEX_HH
2 #define FIT_COMPLEX_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:17:54 GMT
5 
6 #include <string>
7 #include <iostream>
8 #include <complex>
9 #include <string>
10 #include "Mint/counted_ptr.h"
11 
12 #include "Mint/NamedParameter.h"
14 
16 #include "Mint/FitParameter.h"
17 #include "Mint/IReturnComplex.h"
18 
19 #include "Mint/FitParDependent.h"
20 
21 #include "Mint/Phase.h"
22 
23 namespace MINT{
24  class FitComplex
25  : virtual public IReturnComplex
26  , public FitParDependent
27  {
28  // FitComplex(const FitComplex& ){};
29  // no copying for now.
30  // dangerous because for each
31  // FitParameter, a pointer
32  // is held in MinuitParametSet.
33  // Anyway, what would the copied parameter
34  // mean?
35  protected:
36  public:
37 
38  enum TYPE{POLAR=0, CARTESIAN=1, UNDEFINED=2};
39 
40  virtual TYPE type()const=0;
41 
42  virtual FitParameter& p1()=0;
43  virtual FitParameter& p2()=0;
44 
45  virtual const FitParameter& p1() const=0;
46  virtual const FitParameter& p2() const=0;
47 
48  virtual void set(std::complex<double> z)=0;
49 
50  virtual std::complex<double> getVal() const=0;
51  virtual std::complex<double> getValInit() const=0;
52  inline bool gotInitialised()const{
53  return p1().gotInitialised() && p2().gotInitialised();
54  }
55  virtual void print(std::ostream& os = std::cout) const;
56 
57  inline double getReal() const{return getVal().real();}
58  inline double getImag() const{return getVal().imag();}
59 
60  inline double getAmp() const{
61  if(! gotInitialised()) return 0;
62  return std::abs(getVal());
63  }
64  inline double getPhase() const {
65  if(! gotInitialised()) return 0;
66  return std::arg(getVal());
67  }
68 
69  bool isConstant() const;
70  virtual bool isZero() const;
71 
72  virtual operator std::complex<double>() const{
73  return getVal();
74  }
75  virtual std::complex<double> ComplexVal(){
76  return getVal();
77  }
78 
79 
80  FitComplex(IFitParRegister* daddy=0);
81  virtual ~FitComplex(){}
83 
84 
85  std::complex<double> operator-()const{ return - this->getVal();}
86  };
87 
88  counted_ptr<FitComplex> FitComplexMaker(const std::string& name
89  , const char* fname=0
90  , MinuitParameterSet* pset=0
91  , MINT::IFitParRegister* daddy=0
96  );
97 
98 }//namespace MINT
99 
100 std::complex<double> operator*(const std::complex<double>& cplx
101  , const MINT::FitComplex& fc);
102 std::complex<double> operator*(const MINT::FitComplex& fc
103  ,const std::complex<double>& cplx);
104 
105 std::complex<double> operator+(const std::complex<double>& cplx
106  , const MINT::FitComplex& fc);
107 std::complex<double> operator+(const MINT::FitComplex& fc
108  ,const std::complex<double>& cplx);
109 
110 std::complex<double> operator-(const std::complex<double>& cplx
111  , const MINT::FitComplex& fc);
112 std::complex<double> operator-(const MINT::FitComplex& fc
113  ,const std::complex<double>& cplx);
114 
115 std::complex<double> operator/(const std::complex<double>& cplx
116  , const MINT::FitComplex& fc);
117 std::complex<double> operator/(const MINT::FitComplex& fc
118  ,const std::complex<double>& cplx);
119 
120 std::ostream& operator<<(std::ostream& os, const MINT::FitComplex& fc);
121 
122 #endif
123 //
bool isConstant() const
Definition: FitComplex.cpp:68
virtual FitParameter & p1()=0
virtual ~FitComplex()
Definition: FitComplex.h:81
virtual TYPE type() const =0
virtual FitParameter & p2()=0
double getImag() const
Definition: FitComplex.h:58
double getAmp() const
Definition: FitComplex.h:60
virtual bool isZero() const
Definition: FitComplex.cpp:72
virtual std::complex< double > getVal() const =0
std::ostream & operator<<(std::ostream &os, const MINT::FitComplex &fc)
Definition: FitComplex.cpp:122
void setParameterSet(MinuitParameterSet *pset)
Definition: FitComplex.cpp:75
std::complex< double > operator/(const std::complex< double > &cplx, const MINT::FitComplex &fc)
Definition: FitComplex.cpp:113
std::complex< double > operator-(const std::complex< double > &cplx, const MINT::FitComplex &fc)
Definition: FitComplex.cpp:104
counted_ptr< FitComplex > FitComplexMaker(const std::string &name, const char *fname=0, MinuitParameterSet *pset=0, MINT::IFitParRegister *daddy=0, FitParameter::FIX_OR_WHAT fow=FitParameter::FIX, NamedParameterBase::VERBOSITY vb=NamedParameterBase::VERBOSE)
Definition: FitComplex.cpp:17
virtual void set(std::complex< double > z)=0
std::complex< double > operator+(const std::complex< double > &cplx, const MINT::FitComplex &fc)
Definition: FitComplex.cpp:95
virtual void print(std::ostream &os=std::cout) const
Definition: FitComplex.cpp:81
virtual std::complex< double > getValInit() const =0
bool gotInitialised() const
Definition: FitComplex.h:52
double getPhase() const
Definition: FitComplex.h:64
virtual std::complex< double > ComplexVal()
Definition: FitComplex.h:75
std::complex< double > operator *(const std::complex< double > &cplx, const MINT::FitComplex &fc)
Definition: FitComplex.cpp:86
double getReal() const
Definition: FitComplex.h:57
std::complex< double > operator-() const
Definition: FitComplex.h:85
FitComplex(IFitParRegister *daddy=0)
Definition: FitComplex.cpp:66