laura is hosted by Hepforge, IPPP Durham
Laura++  v3r1
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 
24 
25 Double_t LauAbsCoeffSet::minMagnitude_ = -10.0;
26 Double_t LauAbsCoeffSet::maxMagnitude_ = 10.0;
29 Double_t LauAbsCoeffSet::minRealImagPart_ = -10.0;
30 Double_t LauAbsCoeffSet::maxRealImagPart_ = 10.0;
31 Double_t LauAbsCoeffSet::minDelta_ = -2.0;
32 Double_t LauAbsCoeffSet::maxDelta_ = 2.0;
33 
34 LauAbsCoeffSet::LauAbsCoeffSet(const TString& theName, const TString& theBaseName) :
35  name_(theName),
36  basename_(theBaseName),
37  index_(0)
38 {
39 }
40 
42  name_(rhs.name_),
43  basename_(rhs.basename_),
44  index_(rhs.index_)
45 {
46 }
47 
49 {
50  if ( &rhs != this ) {
51  name_ = rhs.name_;
52  basename_ = rhs.basename_;
53  index_ = rhs.index_;
54  }
55  return *this;
56 }
57 
58 void LauAbsCoeffSet::index(UInt_t newIndex)
59 {
60  index_ = newIndex;
61 
62  const TString oldBaseName( this->baseName() );
63  TString basename( oldBaseName );
64  if ( basename.Length() != 1 ) {
65  basename.Remove(1);
66  }
67  basename += newIndex;
68  basename += "_";
69  this->baseName(basename);
70 
71  std::vector<LauParameter*> pars = this->getParameters();
72  for ( std::vector<LauParameter*>::iterator iter = pars.begin(); iter != pars.end(); ++iter ) {
73  this->adjustName( *iter, oldBaseName );
74  }
75 }
76 
77 void LauAbsCoeffSet::adjustName(LauParameter* par, const TString& oldBaseName)
78 {
79  TString theName(par->name());
80  if ( theName.BeginsWith( oldBaseName ) && theName != oldBaseName ) {
81  theName.Remove(0,oldBaseName.Length());
82  }
83  theName.Prepend(this->baseName());
84  par->name(theName);
85 }
86 
87 void LauAbsCoeffSet::setParameterValue(const TString& parName, Double_t value, Bool_t init)
88 {
89  LauParameter* par = this->findParameter( parName );
90  if ( par == 0 ) {
91  std::cerr << "ERROR in LauAbsCoeffSet::setParameterValue : Unable to find parameter \"" << parName << "\"" << std::endl;
92  return;
93  }
94 
95  par->value( value );
96  if ( init ) {
97  par->genValue( value );
98  par->initValue( value );
99  }
100 }
101 
102 void LauAbsCoeffSet::setParameterError(const TString& parName, Double_t error)
103 {
104  LauParameter* par = this->findParameter( parName );
105  if ( par == 0 ) {
106  std::cerr << "ERROR in LauAbsCoeffSet::setParameterError : Unable to find parameter \"" << parName << "\"" << std::endl;
107  return;
108  }
109 
110  par->error( error );
111 }
112 
113 void LauAbsCoeffSet::fixParameter(const TString& parName)
114 {
115  LauParameter* par = this->findParameter( parName );
116  if ( par == 0 ) {
117  std::cerr << "ERROR in LauAbsCoeffSet::fixParameter : Unable to find parameter \"" << parName << "\"" << std::endl;
118  return;
119  }
120 
121  par->fixed( kTRUE );
122 }
123 
124 void LauAbsCoeffSet::floatParameter(const TString& parName)
125 {
126  LauParameter* par = this->findParameter( parName );
127  if ( par == 0 ) {
128  std::cerr << "ERROR in LauAbsCoeffSet::floatParameter : Unable to find parameter \"" << parName << "\"" << std::endl;
129  return;
130  }
131 
132  par->fixed( kFALSE );
133 }
134 
135 void LauAbsCoeffSet::blindParameter(const TString& parName, const TString& blindingString, const Double_t width)
136 {
137  LauParameter* par = this->findParameter( parName );
138  if ( par == 0 ) {
139  std::cerr << "ERROR in LauAbsCoeffSet::blindParameter : Unable to find parameter \"" << parName << "\"" << std::endl;
140  return;
141  }
142 
143  par->blindParameter( blindingString, width );
144 }
145 
146 void LauAbsCoeffSet::addGaussianConstraint(const TString& parName, const Double_t mean, const Double_t width)
147 {
148  LauParameter* par = this->findParameter( parName );
149  if ( par == 0 ) {
150  std::cerr << "ERROR in LauAbsCoeffSet::addGaussianConstraint : Unable to find parameter \"" << parName << "\"" << std::endl;
151  return;
152  }
153 
154  par->addGaussianConstraint( mean, width );
155 }
156 
157 void LauAbsCoeffSet::addSuffixToParameterName(const TString& parName, const TString& suffix)
158 {
159  LauParameter* par = this->findParameter( parName );
160  if ( par == 0 ) {
161  std::cerr << "ERROR in LauAbsCoeffSet::addSuffixToParameterName : Unable to find parameter \"" << parName << "\"" << std::endl;
162  return;
163  }
164 
165  TString newName( par->name() );
166  if ( ! suffix.BeginsWith('_') ) {
167  newName += "_";
168  }
169  newName += suffix;
170  par->name( newName );
171 }
172 
174 {
175  std::vector<LauParameter*> pars = this->getParameters();
176  for ( std::vector<LauParameter*>::iterator iter = pars.begin(); iter != pars.end(); ++iter ) {
177 
178  const TString& iName = (*iter)->name();
179 
180  if ( iName.EndsWith( parName ) ) {
181  return (*iter);
182  }
183  }
184 
185  return 0;
186 }
187 
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.
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.
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.
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.
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.