laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauEFKLLMRes.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2015 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 "LauEFKLLMRes.hh"
30 
31 #include "Lau1DCubicSpline.hh"
32 #include "LauKinematics.hh"
33 #include "LauResonanceInfo.hh"
34 #include "LauTextFileParser.hh"
35 
36 #include <cstdlib>
37 
40 
42  const Int_t resPairAmpInt,
43  const LauDaughters* daughters ) :
44  LauAbsResonance( resInfo, resPairAmpInt, daughters ),
45  massFactor_( 0 )
46 {
47  const Double_t massFactorVal = 0.;
48 
49  const TString& parNameBase = this->getSanitisedName();
50 
51  TString massFactorName( parNameBase );
52  massFactorName += "_massFactor";
53  massFactor_ = resInfo->getExtraParameter( massFactorName );
54  if ( massFactor_ == 0 ) {
55  massFactor_ = new LauParameter( massFactorName, massFactorVal, -10.0, 10.0, kTRUE );
56  massFactor_->secondStage( kTRUE );
57  resInfo->addExtraParameter( massFactor_ );
58  }
59 }
60 
62 {
63 }
64 
66 {
67 }
68 
69 void LauEFKLLMRes::setResonanceParameter( const TString& name, const Double_t value )
70 {
71  if ( name == "massFactor" ) {
72  this->setMassFactor( value );
73  std::cout << "INFO in LauEFKLLMRes::setResonanceParameter: Mass factor set to " << value
74  << std::endl;
75  } else {
76  std::cerr << "WARNING in LauEFKLLMRes::setResonanceParameter: Parameter name not reconised."
77  << std::endl;
78  }
79 }
80 
82 {
83  if ( name == "massFactor" ) {
84  if ( massFactor_->fixed() ) {
85  massFactor_->fixed( kFALSE );
87  } else {
88  std::cerr << "WARNING in LauEFKLLMRes::floatResonanceParameter: Parameter already floating. No parameter changes made."
89  << std::endl;
90  }
91  } else {
92  std::cerr << "WARNING in LauEFKLLMRes::floatResonanceParameter: Parameter name not reconised."
93  << std::endl;
94  }
95 }
96 
98 {
99  if ( name == "massFactor" ) {
100  return massFactor_;
101  } else {
102  std::cerr << "WARNING in LauEFKLLMRes::getResonanceParameter: Parameter name not reconised."
103  << std::endl;
104  return 0;
105  }
106 }
107 
108 const std::vector<LauParameter*>& LauEFKLLMRes::getFloatingParameters()
109 {
110  this->clearFloatingParameters();
111 
112  if ( ! this->fixMassFactor() ) {
114  }
115 
116  return this->getParameters();
117 }
118 
119 LauComplex LauEFKLLMRes::resAmp( Double_t mass, Double_t /*spinTerm*/ )
120 {
121  LauComplex amp( 0.0, 0.0 );
122 
123  if ( magSpline_ == 0 || phaseSpline_ == 0 ) {
124  std::cerr << "ERROR in LauEFKLLMRes::resAmp : One of the splines is null." << std::endl;
125  return amp;
126  }
127 
128  const Double_t massSq = mass * mass;
129  const Double_t mag = magSpline_->evaluate( massSq );
130  const Double_t phase = TMath::DegToRad() * phaseSpline_->evaluate( massSq );
131  LauComplex ff( mag * TMath::Cos( phase ), mag * TMath::Sin( phase ) );
132 
133  amp = ff.scale( TMath::Power( mass, this->getMassFactor() ) );
134 
135  return amp;
136 }
137 
138 void LauEFKLLMRes::setupFormFactor( const TString& inputFile )
139 {
140  LauTextFileParser readFile( inputFile );
141  readFile.processFile();
142 
143  std::vector<Double_t> mSqVals;
144  std::vector<Double_t> magVals;
145  std::vector<Double_t> phaseVals;
146 
147  std::vector<std::string> line;
148 
149  line = readFile.getNextLine();
150  while ( ! line.empty() ) {
151  UInt_t length = line.size();
152  if ( length != 3 ) {
153  std::cerr << "ERROR in LauEFKLLMRes::setupFormFactor : Unexpected number of fields in text file, aborting reading of form-factor information."
154  << std::endl;
155  return;
156  }
157  mSqVals.push_back( atof( line[0].c_str() ) );
158  magVals.push_back( atof( line[1].c_str() ) );
159  phaseVals.push_back( atof( line[2].c_str() ) );
160  line = readFile.getNextLine();
161  }
162 
163  // Destroy any splines we already had defined but issue a warning just in case
164  if ( magSpline_ != 0 || phaseSpline_ != 0 ) {
165  std::cerr << "WARNING in LauEFKLLMRes::setupFormFactor : Overwriting previous form-factor splines with newly read values."
166  << std::endl;
167  delete magSpline_;
168  delete phaseSpline_;
169  }
170  magSpline_ = new Lau1DCubicSpline( mSqVals, magVals, Lau1DCubicSpline::AkimaSpline );
171  phaseSpline_ = new Lau1DCubicSpline( mSqVals, phaseVals, Lau1DCubicSpline::AkimaSpline );
172 }
173 
174 void LauEFKLLMRes::setMassFactor( const Double_t massFactor )
175 {
176  massFactor_->value( massFactor );
177  massFactor_->genValue( massFactor );
178  massFactor_->initValue( massFactor );
179 }
virtual LauComplex resAmp(Double_t mass, Double_t spinTerm)
Complex resonant amplitude.
File containing declaration of LauResonanceInfo class.
const TString & getSanitisedName() const
Get the name of the resonance.
Class for defining the fit parameter objects.
Definition: LauParameter.hh:49
LauComplex scale(Double_t scaleVal) const
Obtain the complex number scaled by some factor.
Definition: LauComplex.hh:292
Double_t value() const
The value of the parameter.
Class for parsing text files.
Double_t getMassFactor() const
Get the power of the mass dependence.
Bool_t fixMassFactor() const
See if the mass factor parameter is fixed or floating.
std::vector< LauParameter * > & getParameters()
Access the list of floating parameters.
virtual ~LauEFKLLMRes()
Destructor.
Definition: LauEFKLLMRes.cc:61
LauParameter * getExtraParameter(const TString &parName)
Retrieve an extra parameter of the resonance.
Bool_t secondStage() const
Check whether the parameter should be floated only in the second stage of a two stage fit.
Class for defining a complex number.
Definition: LauComplex.hh:61
Class for defining a 1D cubic spline based on a set of knots.
void addFloatingParameter(LauParameter *param)
Add parameter to the list of floating parameters.
virtual LauParameter * getResonanceParameter(const TString &name)
Access the given resonance parameter.
Definition: LauEFKLLMRes.cc:97
static void setupFormFactor(const TString &inputFile)
Read the form factor information from text file.
virtual void floatResonanceParameter(const TString &name)
Allow the various parameters to float in the fit.
Definition: LauEFKLLMRes.cc:81
File containing declaration of Lau1DCubicSpline class.
virtual const std::vector< LauParameter * > & getFloatingParameters()
Retrieve the resonance parameters, e.g. so that they can be loaded into a fit.
LauEFKLLMRes(LauResonanceInfo *resInfo, const Int_t resPairAmpInt, const LauDaughters *daughters)
Constructor.
Definition: LauEFKLLMRes.cc:41
virtual void setResonanceParameter(const TString &name, const Double_t value)
Set value of a resonance parameter.
Definition: LauEFKLLMRes.cc:69
void addExtraParameter(LauParameter *param, const Bool_t independentPar=kFALSE)
Add an extra parameter of the resonance.
Bool_t fixed() const
Check whether the parameter is fixed or floated.
LauParameter()
Default constructor.
Definition: LauParameter.cc:40
File containing declaration of LauTextFileParser class.
Class for defining the properties of a resonant particle.
virtual void initialise()
Initialise the model.
Definition: LauEFKLLMRes.cc:65
const TString & name() const
The parameter name.
void processFile()
Parse the file.
LauParameter * massFactor_
The power of the mass dependence.
void clearFloatingParameters()
Clear list of floating parameters.
Abstract class for defining type for resonance amplitude models (Breit-Wigner, Flatte etc....
void setMassFactor(const Double_t massFactor)
Set the power of the mass dependence.
static Lau1DCubicSpline * magSpline_
Spline describing the magnitude variation of the form-factor.
static Lau1DCubicSpline * phaseSpline_
Spline describing the phase variation of the form-factor.
Double_t genValue() const
The value generated for the parameter.
Double_t evaluate(Double_t x) const
Evaluate the function at given point.
Class that defines the particular 3-body decay under study.
Definition: LauDaughters.hh:47
File containing declaration of LauEFKLLMRes class.
std::vector< std::string > getNextLine()
Retrieve the next line.
Double_t initValue() const
The initial value of the parameter.
File containing declaration of LauKinematics class.