laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
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 "LauAbsModIndPartWave.hh"
30 
31 #include "LauConstants.hh"
32 #include "LauKinematics.hh"
33 #include "LauResonanceInfo.hh"
34 
35 #include <cstdlib>
36 #include <iostream>
37 
39  Int_t resPairAmpInt,
40  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
94  << " is below the lower kinematic limit." << std::endl;
95  std::cerr << " : Lower kinematic limit is at mass "
96  << lower_limit << std::endl;
97  std::cerr << " : Aborting definition of knot positions."
98  << std::endl;
99  knots.clear();
100  return knots;
101  }
102  if ( *last > upper_limit ) {
103  std::cerr << "WARNING in LauAbsModIndPartWave::checkKnots : Knot found at mass " << *last
104  << " is above the upper kinematic limit." << std::endl;
105  std::cerr << " : Upper kinematic limit is at mass "
106  << upper_limit << std::endl;
107  std::cerr << " : Aborting definition of knot positions."
108  << std::endl;
109  knots.clear();
110  return knots;
111  }
112 
113  // check if we have knots at each extreme - if not, add them in
114  if ( ( *first ) != lower_limit ) {
115  knots.insert( lower_limit );
116  }
117  if ( ( *last ) != upper_limit ) {
118  knots.insert( upper_limit );
119  }
120 
121  return knots;
122 }
123 
124 void LauAbsModIndPartWave::defineKnots( const std::set<Double_t>& masses )
125 {
126  if ( ! masses_.empty() ) {
127  std::cerr << "WARNING in LauAbsModIndPartWave::defineKnots : Knot positions have already been defined, not making any changes."
128  << std::endl;
129  return;
130  }
131 
132  const std::set<Double_t> knots = this->checkKnots( masses );
133 
134  nKnots_ = knots.size();
135  if ( nKnots_ == 0 ) {
136  return;
137  }
138 
139  masses_.reserve( nKnots_ );
140  amp1Vals_.reserve( nKnots_ );
141  amp2Vals_.reserve( nKnots_ );
142  amp1Pars_.reserve( nKnots_ );
143  amp2Pars_.reserve( nKnots_ );
144 
145  UInt_t counter( 0 );
146  for ( std::set<Double_t>::const_iterator iter = knots.begin(); iter != knots.end(); ++iter ) {
147  masses_.push_back( *iter );
148  amp1Vals_.push_back( 1.0 );
149  amp2Vals_.push_back( 1.0 );
150  this->createAmpParameters( counter );
151  ++counter;
152  }
153 
154  for ( std::vector<Double_t>::const_iterator iter = masses_.begin(); iter != masses_.end();
155  ++iter ) {
156  std::cout << "INFO in LauAbsModIndPartWave::defineKnots : Knot added to resonance "
157  << this->getResonanceName() << " at mass " << *iter << std::endl;
158  }
159 }
160 
162 {
163  if ( spline1_ != 0 ) {
164  delete spline1_;
165  spline1_ = 0;
166  }
167  if ( spline2_ != 0 ) {
168  delete spline2_;
169  spline2_ = 0;
170  }
171 
172  for ( UInt_t i( 0 ); i < nKnots_; ++i ) {
173  amp1Vals_[i] = amp1Pars_[i]->unblindValue();
174  amp2Vals_[i] = amp2Pars_[i]->unblindValue();
175  }
176 
178  amp1Vals_,
179  type1_,
180  leftBound1_,
181  rightBound1_,
182  leftGrad1_,
183  rightGrad1_ );
185  amp2Vals_,
186  type2_,
187  leftBound2_,
188  rightBound2_,
189  leftGrad2_,
190  rightGrad2_ );
191 }
192 
193 LauComplex LauAbsModIndPartWave::resAmp( Double_t mass, Double_t spinTerm )
194 {
195  amp_.zero();
196 
197  Bool_t paramChanged1( kFALSE ), paramChanged2( kFALSE );
198 
199  for ( UInt_t i( 0 ); i < nKnots_; ++i ) {
200  if ( ! amp1Pars_[i]->fixed() && amp1Pars_[i]->unblindValue() != amp1Vals_[i] ) {
201  paramChanged1 = kTRUE;
202  amp1Vals_[i] = amp1Pars_[i]->unblindValue();
203  }
204  if ( ! amp2Pars_[i]->fixed() && amp2Pars_[i]->unblindValue() != amp2Vals_[i] ) {
205  paramChanged2 = kTRUE;
206  amp2Vals_[i] = amp2Pars_[i]->unblindValue();
207  }
208  }
209 
210  if ( spline1_ == 0 || spline2_ == 0 ) {
211  std::cerr << "ERROR in LauAbsModIndPartWave::resAmp : One of the splines is null"
212  << std::endl;
213  return amp_;
214  }
215 
216  if ( paramChanged1 ) {
218  }
219 
220  if ( paramChanged2 ) {
222  }
223 
224  this->evaluateAmplitude( mass );
225 
226  amp_.rescale( spinTerm );
227 
228  return amp_;
229 }
230 
233 {
234  type1_ = type1;
235  type2_ = type2;
236 }
237 
243  Double_t leftGrad1,
244  Double_t rightGrad1,
245  Double_t leftGrad2,
246  Double_t rightGrad2 )
247 {
248  leftBound1_ = leftBound1;
249  rightBound1_ = rightBound1;
250  leftBound2_ = leftBound2;
251  rightBound2_ = rightBound2;
252  leftGrad1_ = leftGrad1;
253  rightGrad1_ = rightGrad1;
254  leftGrad2_ = leftGrad2;
255  rightGrad2_ = rightGrad2;
256 }
257 
258 const std::vector<LauParameter*>& LauAbsModIndPartWave::getFloatingParameters()
259 {
260  this->clearFloatingParameters();
261 
262  for ( UInt_t i( 0 ); i < nKnots_; ++i ) {
263  if ( ! amp1Pars_[i]->fixed() ) {
264  this->addFloatingParameter( amp1Pars_[i] );
265  }
266  if ( ! amp2Pars_[i]->fixed() ) {
267  this->addFloatingParameter( amp2Pars_[i] );
268  }
269  }
270 
271  return this->getParameters();
272 }
virtual void initialise()
Initialise the model.
File containing declaration of LauResonanceInfo class.
Bool_t secondStage_
Flag to determine if the parameters should be floated only in the second stage of the fit.
virtual ~LauAbsModIndPartWave()
Destructor.
Double_t leftGrad2_
The gradient at the left boundary for the second spline if clamped.
const TString & getResonanceName() const
Get the name of the resonance.
Double_t unblindValue() const
The unblinded value of the parameter.
LauAbsModIndPartWave(LauResonanceInfo *resInfo, Int_t resPairAmpInt, const LauDaughters *daughters)
Constructor.
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.
LauComplex amp_
The current value of the amplitude.
std::vector< LauParameter * > & getParameters()
Access the list of floating parameters.
Lau1DCubicSpline * spline1_
The spline used to interpolate the values of the first real parameter.
void setSplineType(Lau1DCubicSpline::LauSplineType type1, Lau1DCubicSpline::LauSplineType type2)
Method to set the type of interpolation used for the splines.
std::vector< Double_t > amp1Vals_
The values of the first real parameter at each knot.
Lau1DCubicSpline::LauSplineBoundaryType leftBound2_
The lower boundary condition type for the second spline.
void defineKnots(const std::set< Double_t > &masses)
Define the knot positions.
Double_t rightGrad1_
The gradient at the right boundary for the first spline if clamped.
void zero()
Set both real and imaginary part to zero.
Definition: LauComplex.hh:331
Lau1DCubicSpline::LauSplineType type2_
The type of interpolation used for the second spline.
Bool_t secondStage() const
Check whether the parameter should be floated only in the second stage of a two stage fit.
std::vector< Double_t > amp2Vals_
The values of the second real parameter at each knot.
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.
Class for defining a complex number.
Definition: LauComplex.hh:61
void updateYValues(const std::vector< Double_t > &ys)
Update the y-values of the knots.
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.
void rescale(Double_t scaleVal)
Scale this by a factor.
Definition: LauComplex.hh:301
LauSplineType
Define the allowed interpolation types.
UInt_t nKnots_
The number of knots.
Double_t leftGrad1_
The gradient at the left boundary for the first spline if clamped.
Double_t getMassParent() const
Get the parent particle mass.
Lau1DCubicSpline::LauSplineType type1_
The type of interpolation used for the first spline.
Lau1DCubicSpline::LauSplineBoundaryType rightBound1_
The upper boundary condition type for the first spline.
virtual std::set< Double_t > checkKnots(const std::set< Double_t > &masses)
Method to check that the supplied knot positions are valid.
Bool_t fixed() const
Check whether the parameter is fixed or floated.
Double_t rightGrad2_
The gradient at the right boundary for the second spline if clamped.
virtual const std::vector< LauParameter * > & getFloatingParameters()
Retrieve the resonance parameters, e.g. so that they can be loaded into a fit.
Class for defining the properties of a resonant particle.
File containing LauConstants namespace.
Double_t getMassDaug1() const
Get the mass of daughter 1.
Lau1DCubicSpline::LauSplineBoundaryType rightBound2_
The upper boundary condition type for the second spline.
std::vector< LauParameter * > amp2Pars_
The parameters for the second real value at the knots.
LauSplineBoundaryType
Define the allowed boundary condition types.
Double_t getMassDaug2() const
Get the mass of daughter 2.
void clearFloatingParameters()
Clear list of floating parameters.
Abstract class for defining type for resonance amplitude models (Breit-Wigner, Flatte etc....
virtual LauComplex resAmp(Double_t mass, Double_t spinTerm)
Complex resonant amplitude.
Lau1DCubicSpline * spline2_
The spline used to interpolate the values of the second real parameter.
Class that defines the particular 3-body decay under study.
Definition: LauDaughters.hh:47
virtual void createAmpParameters(const UInt_t iKnot)=0
Method to create the parameter objects for the given knot.
Lau1DCubicSpline::LauSplineBoundaryType leftBound1_
The lower boundary condition type for the first spline.
Bool_t secondStage_
Flag whether it is floated only in the second stage of the fit.
File containing declaration of LauAbsModIndPartWave class.
Double_t getMassBachelor() const
Get the mass of the bachelor daughter.
Bool_t floatKnotsSecondStage() const
Retrieve the value of the second stage flag.
std::vector< Double_t > masses_
The masses at which knots are defined in the magnitude and phase splines.
File containing declaration of LauKinematics class.