laura is hosted by Hepforge, IPPP Durham
Laura++  v1r2
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  coeff_(x,y)
42 {
43  // Print message
44  cout<<"Set component \""<<this->name()<<"\" to have real part = "<<x_->value()<<" and imaginary part = "<<y_->value()<<"."<<endl;
45 }
46 
48 {
49  minPar_ = rhs.minPar_;
50  maxPar_ = rhs.maxPar_;
51  y_ = rhs.x_->createClone(constFactor);
52  y_ = rhs.y_->createClone(constFactor);
53  coeff_ = rhs.coeff_;
54 }
55 
57 {
58  if (&rhs != this) {
59  this->name(rhs.name());
60  minPar_ = rhs.minPar_;
61  maxPar_ = rhs.maxPar_;
62  y_ = rhs.x_->createClone();
63  y_ = rhs.y_->createClone();
64  coeff_ = rhs.coeff_;
65  }
66  return *this;
67 }
68 
69 std::vector<LauParameter*> LauRealImagCoeffSet::getParameters()
70 {
71  std::vector<LauParameter*> pars;
72  pars.push_back(x_);
73  pars.push_back(y_);
74  return pars;
75 }
76 
77 void LauRealImagCoeffSet::printTableHeading(std::ostream& stream)
78 {
79  stream<<"\\begin{tabular}{|l|c|c|}"<<endl;
80  stream<<"\\hline"<<endl;
81  stream<<"Component & Real Part & Imaginary Part \\\\"<<endl;
82  stream<<"\\hline"<<endl;
83 }
84 
85 void LauRealImagCoeffSet::printTableRow(std::ostream& stream)
86 {
87  LauPrint print;
88  TString resName = this->name();
89  resName = resName.ReplaceAll("_", "\\_");
90  stream<<resName<<" & $";
91  print.printFormat(stream, x_->value());
92  stream<<" \\pm ";
93  print.printFormat(stream, x_->error());
94  stream<<"$ & $";
95  print.printFormat(stream, y_->value());
96  stream<<" \\pm ";
97  print.printFormat(stream, y_->error());
98  stream<<"$ \\\\"<<endl;
99 }
100 
102 {
103  if (x_->fixed() == kFALSE) {
104  // Choose a value between -10.0 and 10.0
105  Double_t value = LauRandom::zeroSeedRandom()->Rndm()*20.0 - 10.0;
106  x_->initValue(value); x_->value(value);
107  }
108  if (y_->fixed() == kFALSE) {
109  // Choose a value between -10.0 and 10.0
110  Double_t value = LauRandom::zeroSeedRandom()->Rndm()*20.0 - 10.0;
111  y_->initValue(value); y_->value(value);
112  }
113 }
114 
116 {
117  x_->updatePull();
118  y_->updatePull();
119 }
120 
122 {
124  return coeff_;
125 }
126 
128 {
129  return this->particleCoeff();
130 }
131 
132 void LauRealImagCoeffSet::setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar )
133 {
134  LauComplex average( coeff );
135  average += coeffBar;
136  average.rescale( 0.5 );
137 
138  x_->value( average.re() );
139  y_->value( average.im() );
140 }
141 
143 {
144  TString parName(this->baseName()); parName += "_ACP";
145  return LauParameter(parName,0.0);
146 }
147 
148 LauAbsCoeffSet* LauRealImagCoeffSet::createClone(const TString& newName, Double_t constFactor)
149 {
150  LauAbsCoeffSet* clone = new LauRealImagCoeffSet( *this, constFactor );
151  clone->name( newName );
152  return clone;
153 }
154 
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.
LauComplex coeff_
The complex coefficient.
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.
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.
virtual const LauComplex & particleCoeff()
Retrieve the complex coefficient for a particle.
void setRealImagPart(Double_t realpart, Double_t imagpart)
Set both real and imaginary part.
Definition: LauComplex.hh:311
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 void setCoeffValues(const LauComplex &coeff, const LauComplex &coeffBar)
Set the parameters based on the complex coefficients for particles and antiparticles.
virtual const LauComplex & antiparticleCoeff()
Retrieve the complex coefficient for an antiparticle.