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