MINT2
FitAmplitude.h
Go to the documentation of this file.
1 #ifndef FITAMPLITUDE_HH
2 #define FITAMPLITUDE_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:18:03 GMT
5 
6 #include <string>
7 
8 #include "Mint/counted_ptr.h"
9 
10 #include "Mint/DecayTree.h"
12 
13 #include "Mint/NamedParameter.h"
14 #include "Mint/FitComplex.h"
15 #include "Mint/FitComplexPolar.h"
16 #include "Mint/AmpInitialiser.h"
17 #include "Mint/Amplitude.h"
18 
19 #include "Mint/IDalitzEvent.h"
20 
21 #include "Mint/ComplexProduct.h"
23 
24 #include "Mint/FitParDependent.h"
25 #include "Mint/IFitParRegister.h"
26 
27 #include <complex>
28 
30 : virtual public MINT::IReturnRealForEvent<IDalitzEvent>
31 , virtual public MINT::IReturnComplexForEvent<IDalitzEvent>
32 , public MINT::FitParDependent
33 {
34  public:
35  // enum STRING_USAGE{FULL_NAME, PREFIX, DEFAULT};
36  protected:
37  // members
40  MINT::NamedParameter<double> _fitFraction; // not varied in fit; input or result.
41  mutable MINT::ComplexProduct _preFactors; // dirty, fix one day.
43 
44  std::string _name;
45  static std::string longestNameInList();
46 
47  int _tag;
48 
49  // methods
50  FitAmplitude(const FitAmplitude& other, IFitParRegister* newDaddy=0);
51 
52  public:
53  static void AutogenerateFitFile(const std::string& fname =
54  "protoFitAmplitudeFile.txt"
55  , const DalitzEventPattern& pat =
57  );
58 
59 
60  FitAmplitude(const std::string& yourOwnNameWithoutPrefix
61  , const AmpInitialiser& treeWithOpts
62  , const char* fname=0
63  , MINT::MinuitParameterSet* pset=0
64  // , STRING_USAGE useStringAs = FULL_NAME
65  );
66 
67  FitAmplitude(const std::string& yourOwnNameWithoutPrefix
68  , const AmpInitialiser& treeWithOpts
70  // , STRING_USAGE useStringAs = FULL_NAME
71  );
72  // you decide name and pass decay as DecayTree
73 
74  FitAmplitude(const AmpInitialiser& treeWithOpts
75  , const char* fname=0
76  , MINT::MinuitParameterSet* pset=0
77  );
78 
79  FitAmplitude(const AmpInitialiser& treeWithOpts
81  );
82 
83  // derives name from tree
84  FitAmplitude(const std::string& StandardisedDecayTreeName
85  , const std::string& prefix = ""
86  , const std::string& linshapePrefix = ""
87  , const char* fname=0
88  , MINT::MinuitParameterSet* pset=0
89  );
90  FitAmplitude(const std::string& StandardisedDecayTreeName
91  , const std::string& prefix
92  , const std::string& linshapePrefix
94  );
95  // derives tree from name (if known by NamedDecayTreeList
96  // there is no parsing of decay descriptors or any such thing)
97 
98  bool isZero() const{ return FitAmpPhase().isZero();}
99 
100  bool isConstant() const;
101  bool canBeIgnored() const;
102 
105 
108 
111 
112  bool setLSameFitParameters(int L);
114 
116  // just the copy constructor, but with a name that
117  // explains the behaviour.
118  return FitAmplitude(*this);
119  }
120 
121  void setFraction(double fr){
122  _fitFraction = fr;
123  }
124  double getFraction()const{
125  return (double) _fitFraction;
126  }
127 
128  void setTag(int tag){
129  _tag = tag;
130  }
131 
132  double getTag()const{
133  return (double) _tag;
134  }
135 
136  // std::complex<double> preFactors();
137  std::complex<double> preFactors() const{
138  return _preFactors.ComplexVal();
139  }
141  return _evt_dep_preFactors;
142  }
144  return _evt_dep_preFactors;
145  }
146 
148  return *_FitAmpPhase;}
150  return *_FitAmpPhase;}
151 
152  // std::complex<double> AmpPhase();
153  std::complex<double> AmpPhase() const{
154  if(isZero()) return 0;
155  return FitAmpPhase() * preFactors();
156  }
157 
158  // a few things directly related to Amplitude
159  // (some of these should probably go away
160  // one day, but keep them for now, for compatibility
161  // with previous scheme (where FitAmplitude inherited
162  // from Amplitude)
163  Amplitude& amp(){return _amp;}
164  const Amplitude& amp() const{return _amp;}
165 
167  return amp().theBareDecay();
168  }
170  return amp().getTreePattern();
171  }
173  , double nSigma=3){
174  return amp().MakeBoxes(pat, nSigma);
175  }
177  , TRandom* rnd=gRandom
178  ){
179  return amp().MakeBWBoxes(pat, rnd);
180  }
181 
182 
183 
184 
185  virtual double boxFactor(){
186 /* std::cout << "boxFacror in FitAmplitude " << this->theDecay().oneLiner() << " = " */
187 /* << "norm(" << AmpPhase() << ") * " << Amplitude::boxFactor() */
188 /* << " = " << norm(AmpPhase()) * Amplitude::boxFactor() << std::endl; */
189  return norm(AmpPhase()) * amp().boxFactor();
190  }
191 
192  virtual std::complex<double> getVal(IDalitzEvent& evt);
193 
194  virtual std::complex<double> getVal(IDalitzEvent* evt); //for backwards compatibility
195 
196  virtual std::complex<double> getValWithoutFitParameters(IDalitzEvent& evt){
197  return amp().getVal(evt);
198  }
199 
200  //virtual std::complex<double> getNewVal(IDalitzEvent& evt);
201 
202  virtual std::complex<double> getNewOnePermutationsVal(IDalitzEvent& evt);
203 
204  double Prob(IDalitzEvent& evt){
205  std::complex<double> z = getVal(evt);
206  return z.real()*z.real() + z.imag()*z.imag();
207  }
208 
209  virtual std::complex<double> ComplexVal(IDalitzEvent& evt){ return getVal(evt); }
210  virtual double RealVal(IDalitzEvent& evt){ return Prob(evt); }
211 
212 
213  std::string name() const{
214  return _name;
215  }
216 
217 
218  void multiply(double r); // by value
219  void multiply(const std::complex<double>& z); // by value
221  void multiply(const MINT::counted_ptr<MINT::IReturnComplex>& irc); // by ref
224 
225  FitAmplitude& operator*=(double r);
226  FitAmplitude& operator*=(const std::complex<double>& z);
231 
232  void print(std::ostream& os = std::cout) const;
233 
234 
235  ~FitAmplitude();
236 
237  friend class FitAmpList;
238  friend class FitAmpListBase;
239 };
240 
241 std::ostream& operator<<(std::ostream& os, const FitAmplitude& fa);
242 #endif
243 //
std::complex< double > AmpPhase() const
Definition: FitAmplitude.h:153
Amplitude _amp
Definition: FitAmplitude.h:38
bool isConstant() const
bool isZero() const
Definition: FitAmplitude.h:98
DalitzEventPattern getTreePattern() const
Definition: FitAmplitude.h:169
static void AutogenerateFitFile(const std::string &fname="protoFitAmplitudeFile.txt", const DalitzEventPattern &pat=DalitzEventPattern::NoPattern)
FitAmplitude GetCConjugateFinalStateSameFitParameters() const
FitAmplitude GetDifferentLSameFitParameters(int L) const
std::string name() const
Definition: FitAmplitude.h:213
bool canBeIgnored() const
virtual std::complex< double > getVal(IDalitzEvent &evt)
bool CPConjugateSameFitParameters()
virtual DalitzBoxSet MakeBoxes(const DalitzEventPattern &pat, double nSigma=3)
Definition: Amplitude.cpp:242
DalitzBoxSet MakeBoxes(const DalitzEventPattern &pat, double nSigma=3)
Definition: FitAmplitude.h:172
FitAmplitude(const FitAmplitude &other, IFitParRegister *newDaddy=0)
FitAmplitude & operator *=(double r)
std::complex< double > ComplexVal()
virtual double RealVal(IDalitzEvent &evt)
Definition: FitAmplitude.h:210
MINT::counted_ptr< MINT::FitComplex > _FitAmpPhase
Definition: FitAmplitude.h:39
bool CConjugateInitialStateSameFitParameters()
virtual std::complex< double > getValWithoutFitParameters(IDalitzEvent &evt)
Definition: FitAmplitude.h:196
DecayTree theBareDecay() const
Definition: FitAmplitude.h:166
const MINT::FitComplex & FitAmpPhase() const
Definition: FitAmplitude.h:149
MINT::ComplexProduct _preFactors
Definition: FitAmplitude.h:41
virtual std::complex< double > getVal(IDalitzEvent &evt)
Definition: Amplitude.h:122
virtual double boxFactor()
Definition: Amplitude.h:68
MINT::FitComplex & FitAmpPhase()
Definition: FitAmplitude.h:147
bool CConjugateFinalStateSameFitParameters()
double getFraction() const
Definition: FitAmplitude.h:124
virtual bool isZero() const
Definition: FitComplex.cpp:72
bool setLSameFitParameters(int L)
DalitzEventPattern getTreePattern() const
Definition: Amplitude.h:161
DalitzBWBoxSet MakeBWBoxes(const DalitzEventPattern &pat, TRandom *rnd=gRandom)
Definition: FitAmplitude.h:176
std::string _name
Definition: FitAmplitude.h:44
void setFraction(double fr)
Definition: FitAmplitude.h:121
MINT::NamedParameter< double > _fitFraction
Definition: FitAmplitude.h:40
MINT::ComplexProductForEvent< IDalitzEvent > _evt_dep_preFactors
Definition: FitAmplitude.h:42
void setTag(int tag)
Definition: FitAmplitude.h:128
static const DalitzEventPattern NoPattern
FitAmplitude GetCopySameFitParameters() const
Definition: FitAmplitude.h:115
static std::string longestNameInList()
Amplitude & amp()
Definition: FitAmplitude.h:163
virtual std::complex< double > getNewOnePermutationsVal(IDalitzEvent &evt)
MINT::ComplexProductForEvent< IDalitzEvent > & eventDependentPrefactors()
Definition: FitAmplitude.h:143
std::complex< double > preFactors() const
Definition: FitAmplitude.h:137
virtual std::complex< double > ComplexVal(IDalitzEvent &evt)
Definition: FitAmplitude.h:209
double Prob(IDalitzEvent &evt)
Definition: FitAmplitude.h:204
const Amplitude & amp() const
Definition: FitAmplitude.h:164
FitAmplitude GetCPConjugateSameFitParameters() const
std::ostream & operator<<(std::ostream &os, const FitAmplitude &fa)
DecayTree theBareDecay() const
Definition: Amplitude.h:157
double getTag() const
Definition: FitAmplitude.h:132
const MINT::ComplexProductForEvent< IDalitzEvent > & eventDependentPrefactors() const
Definition: FitAmplitude.h:140
virtual DalitzBWBoxSet MakeBWBoxes(const DalitzEventPattern &pat, TRandom *rnd=gRandom)
Definition: Amplitude.cpp:300
virtual double boxFactor()
Definition: FitAmplitude.h:185
FitAmplitude GetCConjugateInitialStateSameFitParameters() const
void print(std::ostream &os=std::cout) const
void multiply(double r)