laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauAbsModIndPartWave.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2014 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 <cstdlib>
30 #include <iostream>
31 
32 #include "LauConstants.hh"
33 #include "LauKinematics.hh"
34 #include "LauAbsModIndPartWave.hh"
35 #include "LauResonanceInfo.hh"
36 
38 
39 
40 LauAbsModIndPartWave::LauAbsModIndPartWave(LauResonanceInfo* resInfo, Int_t resPairAmpInt, const LauDaughters* daughters) :
41  LauAbsResonance(resInfo, resPairAmpInt, daughters),
42  nKnots_(0),
43  spline1_(0),
44  spline2_(0),
45  type1_(Lau1DCubicSpline::StandardSpline),
46  type2_(Lau1DCubicSpline::StandardSpline),
47  leftBound1_(Lau1DCubicSpline::NotAKnot),
48  rightBound1_(Lau1DCubicSpline::NotAKnot),
49  leftBound2_(Lau1DCubicSpline::NotAKnot),
50  rightBound2_(Lau1DCubicSpline::NotAKnot),
51  leftGrad1_(0.),
52  rightGrad1_(0.),
53  leftGrad2_(0.),
54  rightGrad2_(0.),
55  secondStage_(kFALSE)
56 {
57 }
58 
60 {
61  delete spline1_;
62  delete spline2_;
63 }
64 
66 {
68 
69  // if the parameters have not yet been created we can now just return
70  if ( amp1Pars_.size() != nKnots_ ) {
71  return;
72  }
73 
74  // otherwise we need to toggle their second-stage parameter
75  for ( UInt_t i(0); i < nKnots_; ++i ) {
76  amp1Pars_[i]->secondStage(secondStage_);
77  amp2Pars_[i]->secondStage(secondStage_);
78  }
79 }
80 
81 std::set<Double_t> LauAbsModIndPartWave::checkKnots(const std::set<Double_t>& masses)
82 {
83  std::set<Double_t> knots = masses;
84 
85  const std::set<Double_t>::const_iterator first = knots.begin();
86  const std::set<Double_t>::const_reverse_iterator last = knots.rbegin();
87 
88  const Double_t lower_limit = this->getMassDaug1() + this->getMassDaug2();
89  const Double_t upper_limit = this->getMassParent() - this->getMassBachelor();
90 
91  // check whether we have been given knots at unphysical masses
92  if ( *first < lower_limit ) {
93  std::cerr << "WARNING in LauAbsModIndPartWave::checkKnots : Knot found at mass " << *first << " is below the lower kinematic limit." << std::endl;
94  std::cerr << " : Lower kinematic limit is at mass " << lower_limit << std::endl;
95  std::cerr << " : Aborting definition of knot positions." << std::endl;
96  knots.clear();
97  return knots;
98  }
99  if ( *last > upper_limit ) {
100  std::cerr << "WARNING in LauAbsModIndPartWave::checkKnots : Knot found at mass " << *last << " is above the upper kinematic limit." << std::endl;
101  std::cerr << " : Upper kinematic limit is at mass " << upper_limit << std::endl;
102  std::cerr << " : Aborting definition of knot positions." << std::endl;
103  knots.clear();
104  return knots;
105  }
106 
107  // check if we have knots at each extreme - if not, add them in
108  if ( (*first) != lower_limit ) {
109  knots.insert( lower_limit );
110  }
111  if ( (*last) != upper_limit ) {
112  knots.insert( upper_limit );
113  }
114 
115  return knots;
116 }
117 
118 void LauAbsModIndPartWave::defineKnots(const std::set<Double_t>& masses)
119 {
120  if ( ! masses_.empty() ) {
121  std::cerr << "WARNING in LauAbsModIndPartWave::defineKnots : Knot positions have already been defined, not making any changes." << std::endl;
122  return;
123  }
124 
125  const std::set<Double_t> knots = this->checkKnots( masses );
126 
127  nKnots_ = knots.size();
128  if ( nKnots_ == 0 ) {
129  return;
130  }
131 
132  masses_.reserve(nKnots_);
133  amp1Vals_.reserve(nKnots_);
134  amp2Vals_.reserve(nKnots_);
135  amp1Pars_.reserve(nKnots_);
136  amp2Pars_.reserve(nKnots_);
137 
138  UInt_t counter(0);
139  for ( std::set<Double_t>::const_iterator iter = knots.begin(); iter != knots.end(); ++iter ) {
140  masses_.push_back( *iter );
141  amp1Vals_.push_back(1.0);
142  amp2Vals_.push_back(1.0);
143  this->createAmpParameters(counter);
144  ++counter;
145  }
146 
147  for ( std::vector<Double_t>::const_iterator iter = masses_.begin(); iter != masses_.end(); ++iter ) {
148  std::cout << "INFO in LauAbsModIndPartWave::defineKnots : Knot added to resonance " << this->getResonanceName() << " at mass " << *iter << std::endl;
149  }
150 }
151 
153 {
154  if ( spline1_ != 0 ) {
155  delete spline1_;
156  spline1_ = 0;
157  }
158  if ( spline2_ != 0 ) {
159  delete spline2_;
160  spline2_ = 0;
161  }
162 
163  for ( UInt_t i(0); i < nKnots_; ++i ) {
164  amp1Vals_[i] = amp1Pars_[i]->unblindValue();
165  amp2Vals_[i] = amp2Pars_[i]->unblindValue();
166  }
167 
170 }
171 
172 LauComplex LauAbsModIndPartWave::resAmp(Double_t mass, Double_t spinTerm)
173 {
174  amp_.zero();
175 
176  Bool_t paramChanged1(kFALSE), paramChanged2(kFALSE);
177 
178  for ( UInt_t i(0); i < nKnots_; ++i ) {
179  if ( !amp1Pars_[i]->fixed() && amp1Pars_[i]->unblindValue() != amp1Vals_[i] ) {
180  paramChanged1 = kTRUE;
181  amp1Vals_[i] = amp1Pars_[i]->unblindValue();
182  }
183  if ( !amp2Pars_[i]->fixed() && amp2Pars_[i]->unblindValue() != amp2Vals_[i] ) {
184  paramChanged2 = kTRUE;
185  amp2Vals_[i] = amp2Pars_[i]->unblindValue();
186  }
187  }
188 
189  if ( spline1_ == 0 || spline2_ == 0) {
190  std::cerr << "ERROR in LauAbsModIndPartWave::resAmp : One of the splines is null" << std::endl;
191  return amp_;
192  }
193 
194  if ( paramChanged1 ) {
196  }
197 
198  if ( paramChanged2 ) {
200  }
201 
202  this->evaluateAmplitude( mass );
203 
204  amp_.rescale( spinTerm );
205 
206  return amp_;
207 }
208 
210 {
211  type1_ = type1;
212  type2_ = type2;
213 }
214 
219  Double_t leftGrad1,
220  Double_t rightGrad1,
221  Double_t leftGrad2,
222  Double_t rightGrad2)
223 {
224  leftBound1_ = leftBound1;
225  rightBound1_ = rightBound1;
226  leftBound2_ = leftBound2;
227  rightBound2_ = rightBound2;
228  leftGrad1_ = leftGrad1;
229  rightGrad1_ = rightGrad1;
230  leftGrad2_ = leftGrad2;
231  rightGrad2_ = rightGrad2;
232 }
233 
234 const std::vector<LauParameter*>& LauAbsModIndPartWave::getFloatingParameters()
235 {
236  this->clearFloatingParameters();
237 
238  for ( UInt_t i(0); i < nKnots_; ++i ) {
239  if ( !amp1Pars_[i]->fixed() ) {
240  this->addFloatingParameter( amp1Pars_[i] );
241  }
242  if ( !amp2Pars_[i]->fixed() ) {
243  this->addFloatingParameter( amp2Pars_[i] );
244  }
245  }
246 
247  return this->getParameters();
248 }
249 
Bool_t fixed() const
Check whether the parameter is fixed or floated.
virtual std::set< Double_t > checkKnots(const std::set< Double_t > &masses)
Method to check that the supplied knot positions are valid.
Double_t getMassBachelor() const
Get the mass of the bachelor daughter.
const TString & getResonanceName() const
Get the name of the resonance.
virtual void initialise()
Initialise the model.
LauComplex amp_
The current value of the amplitude.
Abstract base class for defining a model independent partial wave component.
LauSplineBoundaryType
Define the allowed boundary condition types.
File containing declaration of LauResonanceInfo class.
ClassImp(LauAbsCoeffSet)
Double_t rightGrad1_
The gradient at the right boundary for the first spline if clamped.
Double_t getMassParent() const
Get the parent particle mass.
Class for defining the properties of a resonant particle.
Class that defines the particular 3-body decay under study.
Definition: LauDaughters.hh:47
Lau1DCubicSpline::LauSplineType type1_
The type of interpolation used for the first spline.
std::vector< LauParameter * > amp2Pars_
The parameters for the second real value at the knots.
Lau1DCubicSpline::LauSplineBoundaryType rightBound2_
The upper boundary condition type for the second spline.
virtual void createAmpParameters(const UInt_t iKnot)=0
Method to create the parameter objects for the given knot.
Double_t getMassDaug1() const
Get the mass of daughter 1.
virtual const std::vector< LauParameter * > & getFloatingParameters()
Retrieve the resonance parameters, e.g. so that they can be loaded into a fit.
virtual LauComplex resAmp(Double_t mass, Double_t spinTerm)
Complex resonant amplitude.
File containing declaration of LauKinematics class.
Double_t getMassDaug2() const
Get the mass of daughter 2.
void addFloatingParameter(LauParameter *param)
Add parameter to the list of floating parameters.
Lau1DCubicSpline::LauSplineBoundaryType rightBound1_
The upper boundary condition type for the first spline.
std::vector< Double_t > amp2Vals_
The values of the second real parameter at each knot.
virtual ~LauAbsModIndPartWave()
Destructor.
Double_t leftGrad2_
The gradient at the left boundary for the second spline if clamped.
Class for defining a 1D cubic spline based on a set of knots.
Bool_t secondStage() const
Check whether the parameter should be floated only in the second stage of a two stage fit...
std::vector< LauParameter * > & getParameters()
Access the list of floating parameters.
virtual void evaluateAmplitude(const Double_t mass)=0
Evaluate the amplitude at the given point from the splines.
std::vector< LauParameter * > amp1Pars_
The parameters for the first real value at the knots.
Bool_t secondStage_
Flag to determine if the parameters should be floated only in the second stage of the fit...
void updateYValues(const std::vector< Double_t > &ys)
Update the y-values of the knots.
std::vector< Double_t > masses_
The masses at which knots are defined in the magnitude and phase splines.
Double_t leftGrad1_
The gradient at the left boundary for the first spline if clamped.
Abstract class for defining type for resonance amplitude models (Breit-Wigner, Flatte etc...
void rescale(Double_t scaleVal)
Scale this by a factor.
Definition: LauComplex.hh:299
Lau1DCubicSpline * spline1_
The spline used to interpolate the values of the first real parameter.
void zero()
Set both real and imaginary part to zero.
Definition: LauComplex.hh:335
Lau1DCubicSpline::LauSplineBoundaryType leftBound1_
The lower boundary condition type for the first spline.
File containing LauConstants namespace.
Bool_t secondStage_
Flag whether it is floated only in the second stage of the fit.
Double_t unblindValue() const
The unblinded value of the parameter.
void defineKnots(const std::set< Double_t > &masses)
Define the knot positions.
Class for defining a complex number.
Definition: LauComplex.hh:61
Double_t rightGrad2_
The gradient at the right boundary for the second spline if clamped.
std::vector< Double_t > amp1Vals_
The values of the first real parameter at each knot.
UInt_t nKnots_
The number of knots.
Bool_t floatKnotsSecondStage() const
Retrieve the value of the second stage flag.
Lau1DCubicSpline * spline2_
The spline used to interpolate the values of the second real parameter.
void setSplineBoundaryConditions(Lau1DCubicSpline::LauSplineBoundaryType leftBound1, Lau1DCubicSpline::LauSplineBoundaryType rightBound1, Lau1DCubicSpline::LauSplineBoundaryType leftBound2, Lau1DCubicSpline::LauSplineBoundaryType rightBound2, Double_t leftGrad1=0.0, Double_t rightGrad1=0.0, Double_t leftGrad2=0.0, Double_t rightGrad2=0.0)
Method to set the boundary conditions of the splines.
Lau1DCubicSpline::LauSplineBoundaryType leftBound2_
The lower boundary condition type for the second spline.
LauSplineType
Define the allowed interpolation types.
void setSplineType(Lau1DCubicSpline::LauSplineType type1, Lau1DCubicSpline::LauSplineType type2)
Method to set the type of interpolation used for the splines.
Lau1DCubicSpline::LauSplineType type2_
The type of interpolation used for the second spline.
void clearFloatingParameters()
Clear list of floating parameters.
File containing declaration of LauAbsModIndPartWave class.