laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauResonanceInfo.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 "LauResonanceInfo.hh"
30 
31 #include "LauParameter.hh"
32 
33 #include <iostream>
34 
36  const Double_t mass,
37  const Double_t width,
38  const Int_t spin,
39  const Int_t charge,
41  const Double_t bwRadius ) :
42  name_( name ),
43  sanitisedName_( "" ),
44  mass_( 0 ),
45  width_( 0 ),
46  spin_( spin ),
47  charge_( charge ),
48  bwCategory_( bwCategory ),
49  bwRadius_( bwRadius ),
50  conjugate_( 0 ),
51  extraPars_()
52 {
53  this->sanitiseName();
54  mass_ = new LauParameter( sanitisedName_ + "_MASS", mass, 0.0, 3.0 * mass, kTRUE );
55  mass_->secondStage( kTRUE );
56  width_ = new LauParameter( sanitisedName_ + "_WIDTH", width, 0.0, 3.0 * width, kTRUE );
57  width_->secondStage( kTRUE );
58 }
59 
61 {
62  delete mass_;
63  mass_ = 0;
64  delete width_;
65  width_ = 0;
66 
67  for ( std::set<LauParameter*>::iterator iter = extraPars_.begin(); iter != extraPars_.end();
68  ++iter ) {
69  delete ( *iter );
70  }
71  extraPars_.clear();
72 }
73 
75  const TString& newName,
76  const Int_t newCharge ) :
77  name_( newName ),
78  sanitisedName_( "" ),
79  mass_( 0 ),
80  width_( 0 ),
81  spin_( other.spin_ ),
82  charge_( newCharge ),
83  bwCategory_( other.bwCategory_ ),
84  bwRadius_( other.bwRadius_ ),
85  conjugate_( 0 ),
86  extraPars_()
87 {
88  this->sanitiseName();
89  mass_ = other.mass_->createClone( sanitisedName_ + "_MASS" );
90  width_ = other.width_->createClone( sanitisedName_ + "_WIDTH" );
91  for ( std::set<LauParameter*>::iterator iter = other.extraPars_.begin();
92  iter != other.extraPars_.end();
93  ++iter ) {
94  TString parName = ( *iter )->name();
95  parName.Remove( 0, parName.Last( '_' ) );
96  parName.Prepend( sanitisedName_ );
97  LauParameter* par = ( *iter )->createClone( parName );
98  extraPars_.insert( par );
99  }
100 }
101 
103 {
104  Int_t newCharge = -charge_;
105 
106  TString newName( name_ );
107  Ssiz_t index = newName.Index( "+" );
108  if ( index != -1 ) {
109  newName.Replace( index, 1, "-" );
110  } else {
111  index = newName.Index( "-" );
112  if ( index != -1 ) {
113  newName.Replace( index, 1, "+" );
114  }
115  }
116 
117  LauResonanceInfo* conjugate = new LauResonanceInfo( *this, newName, newCharge );
118  conjugate->conjugate_ = this;
119  this->conjugate_ = conjugate;
120 
121  return conjugate;
122 }
123 
125 {
126  LauResonanceInfo* newinfo = new LauResonanceInfo( *this, name, charge_ );
127 
128  sharedParRecords_.push_back( newinfo );
129 
130  return newinfo;
131 }
132 
134 {
135  LauParameter* par( 0 );
136  for ( std::set<LauParameter*>::iterator iter = extraPars_.begin(); iter != extraPars_.end();
137  ++iter ) {
138  if ( ( *iter )->name() == parName ) {
139  par = ( *iter );
140  }
141  }
142  return par;
143 }
144 
145 void LauResonanceInfo::addExtraParameter( LauParameter* param, const Bool_t independentPar )
146 {
147  bool ok = extraPars_.insert( param ).second;
148  if ( ! ok ) {
149  std::cerr << "WARNING in LauResonanceInfo::addExtraParameter : parameter already present, not adding again"
150  << std::endl;
151  return;
152  }
153 
154  if ( conjugate_ != 0 ) {
155  conjugate_->addCloneOfExtraParameter( param, independentPar );
156  }
157 
158  for ( std::vector<LauResonanceInfo*>::iterator iter = sharedParRecords_.begin();
159  iter != sharedParRecords_.end();
160  ++iter ) {
161  ( *iter )->addCloneOfExtraParameter( param, independentPar );
162  }
163 }
164 
165 void LauResonanceInfo::addCloneOfExtraParameter( LauParameter* param, const Bool_t copyNotClone )
166 {
167  TString parName = param->name();
168  parName.Remove( 0, parName.Last( '_' ) );
169  parName.Prepend( sanitisedName_ );
170 
171  LauParameter* cloneParam( 0 );
172  if ( copyNotClone ) {
173  cloneParam = new LauParameter( parName,
174  param->unblindValue(),
175  param->minValue(),
176  param->maxValue(),
177  param->fixed() );
178  cloneParam->secondStage( kTRUE );
179  } else {
180  cloneParam = param->createClone( parName );
181  }
182  extraPars_.insert( cloneParam );
183 }
184 
185 std::ostream& operator<<( std::ostream& stream, const LauResonanceInfo& infoRecord )
186 {
187  stream << infoRecord.getName() << ": ";
188  stream << "mass = " << infoRecord.getMass()->value() << ", ";
189  stream << "width = " << infoRecord.getWidth()->value() << ", ";
190  stream << "spin = " << infoRecord.getSpin() << ", ";
191  Int_t charge = infoRecord.getCharge();
192  if ( charge < 0 ) {
193  stream << "charge = " << infoRecord.getCharge() << ", ";
194  } else {
195  stream << "charge = " << infoRecord.getCharge() << ", ";
196  }
197  stream << "BW radius = " << infoRecord.getBWRadius();
198 
199  return stream;
200 }
201 
203 {
205  sanitisedName_ = sanitisedName_.ReplaceAll( "+", "p" );
206  sanitisedName_ = sanitisedName_.ReplaceAll( "-", "m" );
207  sanitisedName_ = sanitisedName_.ReplaceAll( "*", "st" );
208  sanitisedName_ = sanitisedName_.ReplaceAll( "(", "_" );
209  sanitisedName_ = sanitisedName_.ReplaceAll( ")", "_" );
210  sanitisedName_ = sanitisedName_.ReplaceAll( "[", "_" );
211  sanitisedName_ = sanitisedName_.ReplaceAll( "]", "_" );
212  sanitisedName_ = sanitisedName_.ReplaceAll( "<", "_" );
213  sanitisedName_ = sanitisedName_.ReplaceAll( ">", "_" );
214  sanitisedName_ = sanitisedName_.ReplaceAll( "{", "_" );
215  sanitisedName_ = sanitisedName_.ReplaceAll( "}", "_" );
216  sanitisedName_ = sanitisedName_.ReplaceAll( " ", "_" );
217  sanitisedName_ = sanitisedName_.ReplaceAll( "$", "" );
218  sanitisedName_ = sanitisedName_.ReplaceAll( "%", "" );
219  sanitisedName_ = sanitisedName_.ReplaceAll( "&", "" );
220  sanitisedName_ = sanitisedName_.ReplaceAll( "/", "" );
221  sanitisedName_ = sanitisedName_.ReplaceAll( ":", "" );
222  sanitisedName_ = sanitisedName_.ReplaceAll( ";", "" );
223  sanitisedName_ = sanitisedName_.ReplaceAll( "=", "" );
224  sanitisedName_ = sanitisedName_.ReplaceAll( "\\", "" );
225  sanitisedName_ = sanitisedName_.ReplaceAll( "^", "" );
226  sanitisedName_ = sanitisedName_.ReplaceAll( "|", "" );
227  sanitisedName_ = sanitisedName_.ReplaceAll( ",", "" );
228  sanitisedName_ = sanitisedName_.ReplaceAll( ".", "" );
229  sanitisedName_.Remove( TString::kBoth, '_' );
230 }
Int_t charge_
The charge of the resonant particle.
File containing declaration of LauResonanceInfo class.
Class for defining the fit parameter objects.
Definition: LauParameter.hh:49
Double_t unblindValue() const
The unblinded value of the parameter.
Double_t value() const
The value of the parameter.
void sanitiseName()
Create the sanitised name by removing characters that are illegal in TBranch names.
File containing declaration of LauParameter class.
virtual ~LauResonanceInfo()
Destructor.
LauResonanceInfo * createSharedParameterRecord(const TString &name)
Create another record that will share parameters with this one.
LauParameter * getExtraParameter(const TString &parName)
Retrieve an extra parameter of the resonance.
Double_t minValue() const
The minimum value allowed for the parameter.
void addCloneOfExtraParameter(LauParameter *param, const Bool_t copyNotClone=kFALSE)
Add a clone of an extra parameter of the resonance.
Int_t getCharge() const
Retrieve the charge of the resonant particle.
Bool_t secondStage() const
Check whether the parameter should be floated only in the second stage of a two stage fit.
std::set< LauParameter * > extraPars_
Extra parameters.
LauParameter * getWidth() const
Retrieve the width of the resonant particle.
LauParameter * getMass() const
Retrieve the mass of the resonant particle.
UInt_t getSpin() const
Retrieve the spin of the resonant particle.
LauParameter * createClone(Double_t constFactor=1.0)
Method to create a clone from the parent parameter using the copy constructor.
Double_t maxValue() const
The maximum value allowed for the parameter.
LauResonanceInfo * conjugate_
The conjugate info object.
std::vector< LauResonanceInfo * > sharedParRecords_
Other info objects that share parameters with this one.
LauResonanceInfo * createChargeConjugate()
Create the charge conjugate particle info record.
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
Class for defining the properties of a resonant particle.
LauParameter * width_
The width of the resonant particle.
const TString & name() const
The parameter name.
TString getName() const
Retrieve the name of the resonant particle.
LauResonanceInfo(const TString &name, const Double_t mass, const Double_t width, const Int_t spin, const Int_t charge, const LauBlattWeisskopfFactor::BlattWeisskopfCategory bwCategory, const Double_t bwRadius=4.0)
Constructor.
BlattWeisskopfCategory
Define resonance categories that will share common barrier factor radii.
LauParameter * mass_
The mass of the resonant particle.
TString name_
The parameter name.
Double_t getBWRadius() const
Retrieve the BW radius of the resonant particle.
TString name_
The name of the resonant particle.
std::ostream & operator<<(std::ostream &stream, const LauResonanceInfo &infoRecord)
output operator formatting of an info record
TString sanitisedName_
The name of the resonant particle with illegal characters removed.