MINT2
FitComplex.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:54 GMT
3 #include <cmath>
4 #include <string>
5 
7 
8 #include "Mint/FitComplex.h"
9 #include "Mint/FitComplexPolar.h"
10 #include "Mint/FitComplexCart.h"
11 #include "Mint/FitParDependent.h"
12 #include "Mint/IFitParRegister.h"
13 
14 using namespace std;
15 using namespace MINT;
16 
18  , const char* fname
19  , MinuitParameterSet* pset
20  , IFitParRegister* daddy
23  ){
24  bool dbThis=false;
25  bool verbose=false;
27  ptr_polar(new FitComplexPolar(name, fname, pset, daddy, fow, vb));
28 
30  ptr_euclid(new FitComplexCart(name, fname, pset, daddy, fow, vb));
31 
32  int count=0;
33  counted_ptr<FitComplex> return_ptr(0);
34  counted_ptr<FitComplex> default_ptr(ptr_polar);
35 
36  if( ptr_polar->gotInitialised()){
37  if(dbThis){
38  cout << " FitComplexMaker for " << name
39  << " found polar co-ordinates." << endl;
40  }
41  return_ptr = ptr_polar;
42  count++;
43  }
44  if( ptr_euclid->gotInitialised()){
45  if(dbThis){
46  cout << " FitComplexMaker for " << name
47  << " found Cartesian co-ordinates." << endl;
48  }
49  return_ptr = ptr_euclid;
50  count++;
51  }
52  if(0 == count){
53  if(verbose){
54  cout << " FitComplexMaker WARNING!: " << name
55  << " did not get initialised!" << endl;
56  }
57  return default_ptr;
58  }else if(2 == count){
59  cout << " FitComplexMaker WARNING!: " << name
60  << " got initialised " << count << " times!!" << endl;
61  return default_ptr;
62  }
63  return return_ptr;
64 }
65 
66 FitComplex::FitComplex(IFitParRegister* daddy) : FitParDependent(daddy){}
67 
69  return p1().iFixInit() && p2().iFixInit();
70 }
71 
72 bool FitComplex::isZero() const{
73  return 0 == getAmp();
74 }
76  if(0 == pset) return;
77  p1().addToParSet(pset);
78  p2().addToParSet(pset);
79 }
80 
81 void FitComplex::print(std::ostream& os) const{
82  os << " value " << getVal();
83 }
84 
85 
86 std::complex<double> operator*(const std::complex<double>& cplx
87  , const FitComplex& fc){
88  return cplx * fc.getVal();
89 }
90 std::complex<double> operator*(const FitComplex& fc
91  ,const std::complex<double>& cplx){
92  return fc.getVal() * cplx;
93 }
94 
95 std::complex<double> operator+(const std::complex<double>& cplx
96  , const FitComplex& fc){
97  return cplx + fc.getVal();
98 }
99 std::complex<double> operator+(const FitComplex& fc
100  ,const std::complex<double>& cplx){
101  return fc.getVal() + cplx;
102 }
103 
104 std::complex<double> operator-(const std::complex<double>& cplx
105  , const FitComplex& fc){
106  return cplx - fc.getVal();
107 }
108 std::complex<double> operator-(const FitComplex& fc
109  ,const std::complex<double>& cplx){
110  return fc.getVal() - cplx;
111 }
112 
113 std::complex<double> operator/(const std::complex<double>& cplx
114  , const FitComplex& fc){
115  return cplx / fc.getVal();
116 }
117 std::complex<double> operator/(const FitComplex& fc
118  ,const std::complex<double>& cplx){
119  return fc.getVal()/cplx;
120 }
121 
122 std::ostream& operator<<(std::ostream& os, const FitComplex& fc){
123  fc.print(os);
124  return os;
125 }
126 
127 
128 //
bool isConstant() const
Definition: FitComplex.cpp:68
virtual FitParameter & p1()=0
int iFixInit() const
virtual FitParameter & p2()=0
std::complex< double > operator-(const std::complex< double > &cplx, const FitComplex &fc)
Definition: FitComplex.cpp:104
double getAmp() const
Definition: FitComplex.h:60
std::complex< double > operator+(const std::complex< double > &cplx, const FitComplex &fc)
Definition: FitComplex.cpp:95
virtual bool isZero() const
Definition: FitComplex.cpp:72
virtual std::complex< double > getVal() const =0
std::ostream & operator<<(std::ostream &os, const FitComplex &fc)
Definition: FitComplex.cpp:122
void setParameterSet(MinuitParameterSet *pset)
Definition: FitComplex.cpp:75
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
std::complex< double > operator *(const std::complex< double > &cplx, const FitComplex &fc)
Definition: FitComplex.cpp:86
std::complex< double > operator/(const std::complex< double > &cplx, const FitComplex &fc)
Definition: FitComplex.cpp:113
virtual void print(std::ostream &os=std::cout) const
Definition: FitComplex.cpp:81
bool gotInitialised() const
Definition: FitComplex.h:52
bool addToParSet(MinuitParameterSet *ps)