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