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