laura is hosted by Hepforge, IPPP Durham
Laura++  v3r2
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauAbsCoeffSet.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 
17 #include "TString.h"
18 
19 #include "LauAbsCoeffSet.hh"
20 #include "LauConstants.hh"
21 #include "LauParameter.hh"
22 #include "LauRandom.hh"
23 
25 
26 TRandom* LauAbsCoeffSet::randomiser_ = 0;
27 Double_t LauAbsCoeffSet::minMagnitude_ = -10.0;
28 Double_t LauAbsCoeffSet::maxMagnitude_ = 10.0;
31 Double_t LauAbsCoeffSet::minRealImagPart_ = -10.0;
32 Double_t LauAbsCoeffSet::maxRealImagPart_ = 10.0;
33 Double_t LauAbsCoeffSet::minDelta_ = -2.0;
34 Double_t LauAbsCoeffSet::maxDelta_ = 2.0;
35 
36 LauAbsCoeffSet::LauAbsCoeffSet(const TString& theName, const TString& theBaseName) :
37  name_(theName),
38  basename_(theBaseName),
39  index_(0)
40 {
41 }
42 
44  name_(rhs.name_),
45  basename_(rhs.basename_),
46  index_(rhs.index_)
47 {
48 }
49 
51 {
52  if ( &rhs != this ) {
53  name_ = rhs.name_;
54  basename_ = rhs.basename_;
55  index_ = rhs.index_;
56  }
57  return *this;
58 }
59 
61 {
62  if ( randomiser_ == 0 ) {
64  }
65  return randomiser_;
66 }
67 
68 void LauAbsCoeffSet::index(UInt_t newIndex)
69 {
70  index_ = newIndex;
71 
72  const TString oldBaseName( this->baseName() );
73  TString basename( oldBaseName );
74  if ( basename.Length() != 1 ) {
75  basename.Remove(1);
76  }
77  basename += newIndex;
78  basename += "_";
79  this->baseName(basename);
80 
81  std::vector<LauParameter*> pars = this->getParameters();
82  for ( std::vector<LauParameter*>::iterator iter = pars.begin(); iter != pars.end(); ++iter ) {
83  this->adjustName( *iter, oldBaseName );
84  }
85 }
86 
87 void LauAbsCoeffSet::adjustName(LauParameter* par, const TString& oldBaseName)
88 {
89  TString theName(par->name());
90  if ( theName.BeginsWith( oldBaseName ) && theName != oldBaseName ) {
91  theName.Remove(0,oldBaseName.Length());
92  }
93  theName.Prepend(this->baseName());
94  par->name(theName);
95 }
96 
97 void LauAbsCoeffSet::setParameterValue(const TString& parName, Double_t value, Bool_t init)
98 {
99  LauParameter* par = this->findParameter( parName );
100  if ( par == 0 ) {
101  std::cerr << "ERROR in LauAbsCoeffSet::setParameterValue : Unable to find parameter \"" << parName << "\"" << std::endl;
102  return;
103  }
104 
105  par->value( value );
106  if ( init ) {
107  par->genValue( value );
108  par->initValue( value );
109  }
110 }
111 
112 void LauAbsCoeffSet::setParameterError(const TString& parName, Double_t error)
113 {
114  LauParameter* par = this->findParameter( parName );
115  if ( par == 0 ) {
116  std::cerr << "ERROR in LauAbsCoeffSet::setParameterError : Unable to find parameter \"" << parName << "\"" << std::endl;
117  return;
118  }
119 
120  par->error( error );
121 }
122 
123 void LauAbsCoeffSet::fixParameter(const TString& parName)
124 {
125  LauParameter* par = this->findParameter( parName );
126  if ( par == 0 ) {
127  std::cerr << "ERROR in LauAbsCoeffSet::fixParameter : Unable to find parameter \"" << parName << "\"" << std::endl;
128  return;
129  }
130 
131  par->fixed( kTRUE );
132 }
133 
134 void LauAbsCoeffSet::floatParameter(const TString& parName)
135 {
136  LauParameter* par = this->findParameter( parName );
137  if ( par == 0 ) {
138  std::cerr << "ERROR in LauAbsCoeffSet::floatParameter : Unable to find parameter \"" << parName << "\"" << std::endl;
139  return;
140  }
141 
142  par->fixed( kFALSE );
143 }
144 
145 void LauAbsCoeffSet::blindParameter(const TString& parName, const TString& blindingString, const Double_t width)
146 {
147  LauParameter* par = this->findParameter( parName );
148  if ( par == 0 ) {
149  std::cerr << "ERROR in LauAbsCoeffSet::blindParameter : Unable to find parameter \"" << parName << "\"" << std::endl;
150  return;
151  }
152 
153  par->blindParameter( blindingString, width );
154 }
155 
156 void LauAbsCoeffSet::addGaussianConstraint(const TString& parName, const Double_t mean, const Double_t width)
157 {
158  LauParameter* par = this->findParameter( parName );
159  if ( par == 0 ) {
160  std::cerr << "ERROR in LauAbsCoeffSet::addGaussianConstraint : Unable to find parameter \"" << parName << "\"" << std::endl;
161  return;
162  }
163 
164  par->addGaussianConstraint( mean, width );
165 }
166 
167 void LauAbsCoeffSet::addSuffixToParameterName(const TString& parName, const TString& suffix)
168 {
169  LauParameter* par = this->findParameter( parName );
170  if ( par == 0 ) {
171  std::cerr << "ERROR in LauAbsCoeffSet::addSuffixToParameterName : Unable to find parameter \"" << parName << "\"" << std::endl;
172  return;
173  }
174 
175  TString newName( par->name() );
176  if ( ! suffix.BeginsWith('_') ) {
177  newName += "_";
178  }
179  newName += suffix;
180  par->name( newName );
181 }
182 
184 {
185  std::vector<LauParameter*> pars = this->getParameters();
186  for ( std::vector<LauParameter*>::iterator iter = pars.begin(); iter != pars.end(); ++iter ) {
187 
188  const TString& iName = (*iter)->name();
189 
190  if ( iName.EndsWith( parName ) ) {
191  return (*iter);
192  }
193  }
194 
195  return 0;
196 }
197 
virtual void blindParameter(const TString &parName, const TString &blindingString, const Double_t width)
Blind the named parameter.
static Double_t maxPhase_
Maximum allowed value of phase parameters.
Bool_t fixed() const
Check whether the parameter is fixed or floated.
static Double_t minDelta_
Minimum allowed value of CP-violating real/imaginary part parameters.
TRandom * zeroSeedRandom()
Access the singleton random number generator with seed set from machine clock time (within +-1 sec)...
Definition: LauRandom.cc:30
ClassImp(LauAbsCoeffSet)
virtual void setParameterValue(const TString &parName, Double_t value, Bool_t init)
Set the value of the named parameter.
const TString & name() const
The parameter name.
static TRandom * randomiser_
Random number generator to use for randomising parameter starting values.
File containing declaration of LauAbsCoeffSet class.
virtual void addGaussianConstraint(const TString &parName, const Double_t mean, const Double_t width)
Add Gaussian constraint to the named parameter.
static Double_t maxRealImagPart_
Maximum allowed value of real/imaginary part parameters.
static Double_t maxDelta_
Maximum allowed value of CP-violating real/imaginary part parameters.
LauAbsCoeffSet & operator=(const LauAbsCoeffSet &rhs)
Copy assignment operator.
UInt_t index_
The index number of the coefficient set.
virtual void fixParameter(const TString &parName)
Set the named parameter to be fixed in the fit.
virtual void setParameterError(const TString &parName, Double_t error)
Set the error of the named parameter.
virtual void addSuffixToParameterName(const TString &parName, const TString &suffix)
Add suffix to the name of the given parameter.
LauParameter * findParameter(const TString &parName)
Find the parameter with the given name.
virtual UInt_t index() const
Retrieve the index number of the coefficient set.
const Double_t threePi
Three times Pi.
Definition: LauConstants.hh:95
static Double_t maxMagnitude_
Maximum allowed value of magnitude parameters.
File containing declaration of LauParameter class.
TString basename_
The base name of the coefficient set.
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:35
static Double_t minRealImagPart_
Minimum allowed value of real/imaginary part parameters.
File containing LauRandom namespace.
TString name_
The parameter name.
Double_t initValue() const
The initial value of the parameter.
void blindParameter(const TString &blindingString, const Double_t width)
Blind the parameter.
File containing LauConstants namespace.
virtual void floatParameter(const TString &parName)
Set the named parameter to float in the fit.
void addGaussianConstraint(Double_t newGaussMean, Double_t newGaussWidth)
Add a Gaussian constraint (or modify an existing one)
static Double_t minPhase_
Minimum allowed value of phase parameters.
Double_t value() const
The value of the parameter.
virtual std::vector< LauParameter * > getParameters()=0
Retrieve the parameters of the coefficient so that they can be loaded into a fit. ...
static Double_t minMagnitude_
Minimum allowed value of magnitude parameters.
virtual const TString & baseName() const
Retrieve the base name of the coefficient set.
static TRandom * getRandomiser()
Access the randomiser.
Double_t genValue() const
The value generated for the parameter.
TString name_
The name of the coefficient set.
virtual void adjustName(LauParameter *par, const TString &oldBaseName)
Prepend the base name and index to the name of a parameter.
LauAbsCoeffSet(const TString &theName, const TString &theBaseName="A")
Constructor.