laura is hosted by Hepforge, IPPP Durham
Laura++  v1r0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauRealImagCoeffSet.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2006 - 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
15 #include <iostream>
16 #include <fstream>
17 #include <vector>
18 using std::cout;
19 using std::cerr;
20 using std::endl;
21 
22 #include "TMath.h"
23 #include "TRandom.h"
24 
25 #include "LauComplex.hh"
26 #include "LauConstants.hh"
27 #include "LauRealImagCoeffSet.hh"
28 #include "LauParameter.hh"
29 #include "LauPrint.hh"
30 #include "LauRandom.hh"
31 
32 ClassImp(LauRealImagCoeffSet)
33 
34 
35 LauRealImagCoeffSet::LauRealImagCoeffSet(const TString& compName, Double_t x, Double_t y, Bool_t xFixed, Bool_t yFixed) :
36  LauAbsCoeffSet(compName),
37  minPar_(-10.0),
38  maxPar_(+10.0),
39  x_(new LauParameter("X",x,minPar_,maxPar_,xFixed)),
40  y_(new LauParameter("Y",y,minPar_,maxPar_,yFixed))
41 {
42  // Print message
43  cout<<"Set component \""<<this->name()<<"\" to have real part = "<<x_->value()<<" and imaginary part = "<<y_->value()<<"."<<endl;
44 }
45 
47 {
48  minPar_ = rhs.minPar_;
49  maxPar_ = rhs.maxPar_;
50  y_ = rhs.x_->createClone(constFactor);
51  y_ = rhs.y_->createClone(constFactor);
52 }
53 
55 {
56  if (&rhs == this) {
57  return *this;
58  }
59  this->name(rhs.name());
60  minPar_ = rhs.minPar_;
61  maxPar_ = rhs.maxPar_;
62  y_ = rhs.x_->createClone();
63  y_ = rhs.y_->createClone();
64  return *this;
65 }
66 
67 std::vector<LauParameter*> LauRealImagCoeffSet::getParameters()
68 {
69  std::vector<LauParameter*> pars;
70  pars.push_back(x_);
71  pars.push_back(y_);
72  return pars;
73 }
74 
75 void LauRealImagCoeffSet::printTableHeading(std::ostream& stream)
76 {
77  stream<<"\\begin{tabular}{|l|c|c|}"<<endl;
78  stream<<"\\hline"<<endl;
79  stream<<"Component & Real Part & Imaginary Part \\\\"<<endl;
80  stream<<"\\hline"<<endl;
81 }
82 
83 void LauRealImagCoeffSet::printTableRow(std::ostream& stream)
84 {
85  LauPrint print;
86  TString resName = this->name();
87  resName = resName.ReplaceAll("_", "\\_");
88  stream<<resName<<" & $";
89  print.printFormat(stream, x_->value());
90  stream<<" \\pm ";
91  print.printFormat(stream, x_->error());
92  stream<<"$ & $";
93  print.printFormat(stream, y_->value());
94  stream<<" \\pm ";
95  print.printFormat(stream, y_->error());
96  stream<<"$ \\\\"<<endl;
97 }
98 
100 {
101  if (x_->fixed() == kFALSE) {
102  // Choose a value between -10.0 and 10.0
103  Double_t value = LauRandom::zeroSeedRandom()->Rndm()*20.0 - 10.0;
104  x_->initValue(value); x_->value(value);
105  }
106  if (y_->fixed() == kFALSE) {
107  // Choose a value between -10.0 and 10.0
108  Double_t value = LauRandom::zeroSeedRandom()->Rndm()*20.0 - 10.0;
109  y_->initValue(value); y_->value(value);
110  }
111 }
112 
114 {
115  x_->updatePull();
116  y_->updatePull();
117 }
118 
120 {
121  LauComplex coeff(x_->value(), y_->value());
122  return coeff;
123 }
124 
126 {
127  return this->particleCoeff();
128 }
129 
130 void LauRealImagCoeffSet::setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar )
131 {
132  LauComplex average( coeff );
133  average += coeffBar;
134  average.rescale( 0.5 );
135 
136  x_->value( average.re() );
137  y_->value( average.im() );
138 }
139 
141 {
142  TString parName(this->baseName()); parName += "_ACP";
143  return LauParameter(parName,0.0);
144 }
145 
146 LauAbsCoeffSet* LauRealImagCoeffSet::createClone(const TString& newName, Double_t constFactor)
147 {
148  LauAbsCoeffSet* clone = new LauRealImagCoeffSet( *this, constFactor );
149  clone->name( newName );
150  return clone;
151 }
152 
Bool_t fixed() const
Check whether the parameter is fixed or floated.
TRandom * zeroSeedRandom()
Access the singleton random number generator with seed set from machine clock time (within +-1 sec)...
Definition: LauRandom.cc:30
LauRealImagCoeffSet & operator=(const LauRealImagCoeffSet &rhs)
Copy assignment operator.
virtual void randomiseInitValues()
Randomise the starting values of the parameters for a fit.
virtual TString baseName() const
Retrieve the base name of the coefficient set.
LauParameter()
Default constructor.
Definition: LauParameter.cc:30
const TString & name() const
The parameter name.
LauRealImagCoeffSet(const TString &compName, Double_t x, Double_t y, Bool_t xFixed, Bool_t yFixed)
Constructor.
Double_t re() const
Get the real part.
Definition: LauComplex.hh:202
Double_t im() const
Get the imaginary part.
Definition: LauComplex.hh:211
virtual void printTableHeading(std::ostream &stream)
Print the column headings for a results table.
LauParameter * x_
The real part.
File containing declaration of LauPrint class.
Class to define various output print commands.
Definition: LauPrint.hh:29
Double_t minPar_
The minimum allowed value for parameters.
Bool_t clone() const
Check whether is a clone or not.
virtual void printTableRow(std::ostream &stream)
Print the parameters of the complex coefficient as a row in the results table.
File containing declaration of LauParameter class.
virtual std::vector< LauParameter * > getParameters()
Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit...
File containing declaration of LauComplex class.
virtual LauComplex particleCoeff()
Retrieve the complex coefficient for a particle.
Double_t error() const
The error on the parameter.
Class for defining the abstract interface for complex coefficient classes.
Class for defining the fit parameter objects.
Definition: LauParameter.hh:31
virtual void finaliseValues()
Make sure values are in &quot;standard&quot; ranges, e.g. phases should be between -pi and pi.
File containing LauRandom namespace.
Double_t maxPar_
The maximum allowed value for parameters.
virtual LauParameter acp()
Calculate the CP asymmetry.
void rescale(Double_t scaleVal)
Scale this by a factor.
Definition: LauComplex.hh:282
Double_t initValue() const
The initial value of the parameter.
File containing LauConstants namespace.
virtual LauAbsCoeffSet * createClone(const TString &newName, Double_t constFactor=1.0)
Create a clone of the coefficient set.
Class for defining a complex coefficient using real and imaginary parts.
void printFormat(std::ostream &stream, Double_t value) const
Method to choose the printing format to a specified level of precision.
Definition: LauPrint.cc:32
File containing declaration of LauRealImagCoeffSet class.
Class for defining a complex number.
Definition: LauComplex.hh:47
void updatePull()
Call to update the bias and pull values.
LauParameter * createClone(Double_t constFactor=1.0)
Method to create a clone from the parent parameter using the copy constructor.
virtual TString name() const
Retrieve the name of the coefficient set.
LauParameter * y_
The imaginary part.
Double_t value() const
The value of the parameter.
virtual LauComplex antiparticleCoeff()
Retrieve the complex coefficient for an antiparticle.
virtual void setCoeffValues(const LauComplex &coeff, const LauComplex &coeffBar)
Set the parameters based on the complex coefficients for particles and antiparticles.