laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauRealImagCoeffSet.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2006 University of Warwick
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
18 /*
19 Laura++ package authors:
20 John Back
21 Paul Harrison
22 Thomas Latham
23 */
24 
29 #include "LauRealImagCoeffSet.hh"
30 
31 #include "LauComplex.hh"
32 #include "LauConstants.hh"
33 #include "LauParameter.hh"
34 #include "LauPrint.hh"
35 
36 #include "TMath.h"
37 #include "TRandom.h"
38 
39 #include <fstream>
40 #include <iostream>
41 #include <vector>
42 
44  Double_t x,
45  Double_t y,
46  Bool_t xFixed,
47  Bool_t yFixed ) :
48  LauAbsCoeffSet( compName ),
49  x_( new LauParameter( "X", x, minRealImagPart_, maxRealImagPart_, xFixed ) ),
50  y_( new LauParameter( "Y", y, minRealImagPart_, maxRealImagPart_, yFixed ) ),
51  coeff_( x, y )
52 {
53 }
54 
56  CloneOption cloneOption,
57  Double_t constFactor ) :
58  LauAbsCoeffSet( rhs.name() ),
59  x_( 0 ),
60  y_( 0 ),
61  coeff_( rhs.coeff_ )
62 {
63  if ( cloneOption == All || cloneOption == TieRealPart ) {
64  x_ = rhs.x_->createClone( constFactor );
65  } else {
66  x_ = new LauParameter( "X",
67  rhs.x_->value(),
70  rhs.x_->fixed() );
71  if ( rhs.x_->blind() ) {
72  const LauBlind* blinder = rhs.x_->blinder();
74  }
75  }
76 
77  if ( cloneOption == All || cloneOption == TieImagPart ) {
78  y_ = rhs.y_->createClone( constFactor );
79  } else {
80  y_ = new LauParameter( "Y",
81  rhs.y_->value(),
84  rhs.y_->fixed() );
85  if ( rhs.y_->blind() ) {
86  const LauBlind* blinder = rhs.y_->blinder();
88  }
89  }
90 }
91 
92 std::vector<LauParameter*> LauRealImagCoeffSet::getParameters()
93 {
94  std::vector<LauParameter*> pars;
95  pars.push_back( x_ );
96  pars.push_back( y_ );
97  return pars;
98 }
99 
101 {
102  std::cout << "INFO in LauRealImagCoeffSet::printParValues : Component \"" << this->name()
103  << "\" has real part = " << x_->value() << " and imaginary part = " << y_->value()
104  << "." << std::endl;
105 }
106 
107 void LauRealImagCoeffSet::printTableHeading( std::ostream& stream ) const
108 {
109  stream << "\\begin{tabular}{|l|c|c|}" << std::endl;
110  stream << "\\hline" << std::endl;
111  stream << "Component & Real Part & Imaginary Part \\\\" << std::endl;
112  stream << "\\hline" << std::endl;
113 }
114 
115 void LauRealImagCoeffSet::printTableRow( std::ostream& stream ) const
116 {
117  LauPrint print;
118  TString resName = this->name();
119  resName = resName.ReplaceAll( "_", "\\_" );
120  stream << resName << " & $";
121  print.printFormat( stream, x_->value() );
122  stream << " \\pm ";
123  print.printFormat( stream, x_->error() );
124  stream << "$ & $";
125  print.printFormat( stream, y_->value() );
126  stream << " \\pm ";
127  print.printFormat( stream, y_->error() );
128  stream << "$ \\\\" << std::endl;
129 }
130 
132 {
133  if ( x_->fixed() == kFALSE ) {
134  // Choose a value between -10.0 and 10.0
135  Double_t value = LauAbsCoeffSet::getRandomiser()->Rndm() * 20.0 - 10.0;
136  x_->initValue( value );
137  x_->value( value );
138  }
139  if ( y_->fixed() == kFALSE ) {
140  // Choose a value between -10.0 and 10.0
141  Double_t value = LauAbsCoeffSet::getRandomiser()->Rndm() * 20.0 - 10.0;
142  y_->initValue( value );
143  y_->value( value );
144  }
145 }
146 
148 {
149  x_->updatePull();
150  y_->updatePull();
151 }
152 
154 {
156  return coeff_;
157 }
158 
160 {
161  return this->particleCoeff();
162 }
163 
165  const LauComplex& coeffBar,
166  Bool_t init )
167 {
168  LauComplex average( coeff );
169  average += coeffBar;
170  average.rescale( 0.5 );
171 
172  Double_t xVal( average.re() );
173  Double_t yVal( average.im() );
174 
175  x_->value( xVal );
176  y_->value( yVal );
177 
178  if ( init ) {
179  x_->genValue( xVal );
180  y_->genValue( yVal );
181 
182  x_->initValue( xVal );
183  y_->initValue( yVal );
184  }
185 }
186 
188 {
189  TString parName( this->baseName() );
190  parName += "_ACP";
191  return LauParameter( parName, 0.0 );
192 }
193 
195  CloneOption cloneOption,
196  Double_t constFactor )
197 {
198  LauAbsCoeffSet* clone( 0 );
199  if ( cloneOption == All || cloneOption == TieRealPart || cloneOption == TieImagPart ) {
200  clone = new LauRealImagCoeffSet( *this, cloneOption, constFactor );
201  clone->name( newName );
202  } else {
203  std::cerr << "ERROR in LauRealImagCoeffSet::createClone : Invalid clone option" << std::endl;
204  }
205  return clone;
206 }
Class for defining the abstract interface for complex coefficient classes.
Class for defining the fit parameter objects.
Definition: LauParameter.hh:49
Double_t unblindValue() const
The unblinded value of the parameter.
Double_t value() const
The value of the parameter.
virtual const LauComplex & particleCoeff()
Retrieve the complex coefficient for a particle.
virtual const LauComplex & antiparticleCoeff()
Retrieve the complex coefficient for an antiparticle.
const LauBlind * blinder() const
Access the blinder object.
virtual void printTableHeading(std::ostream &stream) const
Print the column headings for a results table.
virtual LauAbsCoeffSet * createClone(const TString &newName, CloneOption cloneOption=All, Double_t constFactor=1.0)
Create a clone of the coefficient set.
virtual TString name() const
Retrieve the name of the coefficient set.
virtual void finaliseValues()
Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi.
File containing declaration of LauParameter class.
virtual LauParameter acp()
Calculate the CP asymmetry.
virtual const TString & baseName() const
Retrieve the base name of the coefficient set.
Class for defining a complex number.
Definition: LauComplex.hh:61
Bool_t blind() const
The blinding state.
Class for blinding and unblinding a number based on a blinding string.
Definition: LauBlind.hh:42
void rescale(Double_t scaleVal)
Scale this by a factor.
Definition: LauComplex.hh:301
void setRealImagPart(Double_t realpart, Double_t imagpart)
Set both real and imaginary part.
Definition: LauComplex.hh:324
Bool_t clone() const
Check whether is a clone or not.
File containing declaration of LauComplex class.
LauParameter * createClone(Double_t constFactor=1.0)
Method to create a clone from the parent parameter using the copy constructor.
void blindParameter(const TString &blindingString, const Double_t width)
Blind the parameter.
Double_t blindingWidth() const
Obtain the Gaussian width.
Definition: LauBlind.hh:82
Bool_t fixed() const
Check whether the parameter is fixed or floated.
LauParameter()
Default constructor.
Definition: LauParameter.cc:40
LauComplex coeff_
The complex coefficient.
virtual void printParValues() const
Print the current values of the parameters.
File containing LauConstants namespace.
Double_t re() const
Get the real part.
Definition: LauComplex.hh:242
const TString & name() const
The parameter name.
virtual std::vector< LauParameter * > getParameters()
Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit.
LauParameter * x_
The real part.
const TString & blindingString() const
Obtain the blinding string.
Definition: LauBlind.hh:76
Double_t error() const
The error on the parameter.
static TRandom * getRandomiser()
Access the randomiser.
LauRealImagCoeffSet(const TString &compName, Double_t x, Double_t y, Bool_t xFixed, Bool_t yFixed)
Constructor.
void updatePull()
Call to update the bias and pull values.
File containing declaration of LauPrint class and LauOutputLevel enum.
CloneOption
Options for cloning operation.
static Double_t maxRealImagPart_
Maximum allowed value of real/imaginary part parameters.
Class to define various output print commands.
Definition: LauPrint.hh:54
virtual void setCoeffValues(const LauComplex &coeff, const LauComplex &coeffBar, Bool_t init)
Set the parameters based on the complex coefficients for particles and antiparticles.
Double_t genValue() const
The value generated for the parameter.
static Double_t minRealImagPart_
Minimum allowed value of real/imaginary part parameters.
Double_t im() const
Get the imaginary part.
Definition: LauComplex.hh:248
void printFormat(std::ostream &stream, Double_t value) const
Method to choose the printing format to a specified level of precision.
Definition: LauPrint.cc:43
Class for defining a complex coefficient using real and imaginary parts.
File containing declaration of LauRealImagCoeffSet class.
virtual void printTableRow(std::ostream &stream) const
Print the parameters of the complex coefficient as a row in the results table.
LauParameter * y_
The imaginary part.
Double_t initValue() const
The initial value of the parameter.
virtual void randomiseInitValues()
Randomise the starting values of the parameters for a fit.