laura is hosted by Hepforge, IPPP Durham
Laura++  v3r2
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauResonanceInfo.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2006 - 2014.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
15 #include <iostream>
16 
17 #include "LauParameter.hh"
18 #include "LauResonanceInfo.hh"
19 
21 
22 
23 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) :
24  name_(name),
25  sanitisedName_(""),
26  mass_(0),
27  width_(0),
28  spin_(spin),
29  charge_(charge),
30  bwCategory_(bwCategory),
31  bwRadius_(bwRadius),
32  conjugate_(0),
33  extraPars_()
34 {
35  this->sanitiseName();
36  mass_ = new LauParameter(sanitisedName_+"_MASS",mass,0.0,3.0*mass,kTRUE);
37  mass_->secondStage(kTRUE);
38  width_ = new LauParameter(sanitisedName_+"_WIDTH",width,0.0,3.0*width,kTRUE);
39  width_->secondStage(kTRUE);
40 }
41 
43 {
44  delete mass_; mass_ = 0;
45  delete width_; width_ = 0;
46 
47  for ( std::set<LauParameter*>::iterator iter = extraPars_.begin(); iter != extraPars_.end(); ++iter ) {
48  delete (*iter);
49  }
50  extraPars_.clear();
51 }
52 
53 LauResonanceInfo::LauResonanceInfo( const LauResonanceInfo& other, const TString& newName, const Int_t newCharge ) :
54  name_(newName),
55  sanitisedName_(""),
56  mass_(0),
57  width_(0),
58  spin_(other.spin_),
59  charge_(newCharge),
60  bwCategory_(other.bwCategory_),
61  bwRadius_(other.bwRadius_),
62  conjugate_(0),
63  extraPars_()
64 {
65  this->sanitiseName();
66  mass_ = other.mass_->createClone( sanitisedName_+"_MASS" );
67  width_ = other.width_->createClone( sanitisedName_+"_WIDTH" );
68  for ( std::set<LauParameter*>::iterator iter = other.extraPars_.begin(); iter != other.extraPars_.end(); ++iter ) {
69  TString parName = (*iter)->name();
70  parName.Remove(0, parName.Last('_'));
71  parName.Prepend( sanitisedName_ );
72  LauParameter* par = (*iter)->createClone( parName );
73  extraPars_.insert( par );
74  }
75 }
76 
78 {
79  Int_t newCharge = -charge_;
80 
81  TString newName( name_ );
82  Ssiz_t index = newName.Index("+");
83  if ( index != -1 ) {
84  newName.Replace( index, 1, "-" );
85  } else {
86  index = newName.Index("-");
87  if ( index != -1 ) {
88  newName.Replace( index, 1, "+" );
89  }
90  }
91 
92  LauResonanceInfo* conjugate = new LauResonanceInfo( *this, newName, newCharge );
93  conjugate->conjugate_ = this;
94  this->conjugate_ = conjugate;
95 
96  return conjugate;
97 }
98 
100 {
101  LauResonanceInfo* newinfo = new LauResonanceInfo( *this, name, charge_ );
102 
103  sharedParRecords_.push_back(newinfo);
104 
105  return newinfo;
106 }
107 
109 {
110  LauParameter* par(0);
111  for ( std::set<LauParameter*>::iterator iter = extraPars_.begin(); iter != extraPars_.end(); ++iter ) {
112  if ( (*iter)->name() == parName ) {
113  par = (*iter);
114  }
115  }
116  return par;
117 }
118 
119 void LauResonanceInfo::addExtraParameter( LauParameter* param, const Bool_t independentPar )
120 {
121  bool ok = extraPars_.insert( param ).second;
122  if ( !ok ) {
123  std::cerr << "WARNING in LauResonanceInfo::addExtraParameter : parameter already present, not adding again" << std::endl;
124  return;
125  }
126 
127  if ( conjugate_ != 0 ) {
128  conjugate_->addCloneOfExtraParameter( param, independentPar );
129  }
130 
131  for ( std::vector<LauResonanceInfo*>::iterator iter = sharedParRecords_.begin(); iter != sharedParRecords_.end(); ++iter ) {
132  (*iter)->addCloneOfExtraParameter( param, independentPar );
133  }
134 }
135 
136 void LauResonanceInfo::addCloneOfExtraParameter( LauParameter* param, const Bool_t copyNotClone )
137 {
138  TString parName = param->name();
139  parName.Remove(0, parName.Last('_'));
140  parName.Prepend( sanitisedName_ );
141 
142  LauParameter* cloneParam(0);
143  if ( copyNotClone ) {
144  cloneParam = new LauParameter( parName, param->unblindValue(), param->minValue(), param->maxValue(), param->fixed() );
145  cloneParam->secondStage(kTRUE);
146  } else {
147  cloneParam = param->createClone( parName );
148  }
149  extraPars_.insert( cloneParam );
150 }
151 
152 std::ostream& operator<<( std::ostream& stream, const LauResonanceInfo& infoRecord )
153 {
154  stream << infoRecord.getName() << ": ";
155  stream << "mass = " << infoRecord.getMass()->value() << ", ";
156  stream << "width = " << infoRecord.getWidth()->value() << ", ";
157  stream << "spin = " << infoRecord.getSpin() << ", ";
158  Int_t charge = infoRecord.getCharge();
159  if ( charge < 0 ) {
160  stream << "charge = " << infoRecord.getCharge() << ", ";
161  } else {
162  stream << "charge = " << infoRecord.getCharge() << ", ";
163  }
164  stream << "BW radius = " << infoRecord.getBWRadius();
165 
166  return stream;
167 }
168 
170 {
172  sanitisedName_ = sanitisedName_.ReplaceAll("+","p");
173  sanitisedName_ = sanitisedName_.ReplaceAll("-","m");
174  sanitisedName_ = sanitisedName_.ReplaceAll("*","st");
175  sanitisedName_ = sanitisedName_.ReplaceAll("(","_");
176  sanitisedName_ = sanitisedName_.ReplaceAll(")","_");
177  sanitisedName_ = sanitisedName_.ReplaceAll("[","_");
178  sanitisedName_ = sanitisedName_.ReplaceAll("]","_");
179  sanitisedName_ = sanitisedName_.ReplaceAll("<","_");
180  sanitisedName_ = sanitisedName_.ReplaceAll(">","_");
181  sanitisedName_ = sanitisedName_.ReplaceAll("{","_");
182  sanitisedName_ = sanitisedName_.ReplaceAll("}","_");
183  sanitisedName_ = sanitisedName_.ReplaceAll(" ","_");
184  sanitisedName_ = sanitisedName_.ReplaceAll("$","");
185  sanitisedName_ = sanitisedName_.ReplaceAll("%","");
186  sanitisedName_ = sanitisedName_.ReplaceAll("&","");
187  sanitisedName_ = sanitisedName_.ReplaceAll("/","");
188  sanitisedName_ = sanitisedName_.ReplaceAll(":","");
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_.Remove(TString::kBoth,'_');
197 }
198 
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:30
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:43
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:35
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.