ROOTPWA
pwacomponent.h
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 // File and Version Information:
3 // $Id$
4 //
5 // Description:
6 // (BW) Component of mass dependent fit
7 //
8 //
9 // Author List:
10 // Sebastian Neubert TUM (original author)
11 //
12 //
13 //-----------------------------------------------------------
14 
15 #ifndef PWACOMPONENT_HH
16 #define PWACOMPONENT_HH
17 
18 // Base Class Headers ----------------
19 
20 
21 // Collaborating Class Headers -------
22 #include <ostream>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <complex>
27 #include <TGraph.h>
28 
29 // Collaborating Class Declarations --
30 class TF1;
31 
32 namespace rpwa {
33 
34  class pwachannel {
35  public:
36  pwachannel() : _C(0,0),_ps(NULL){}
37  pwachannel(std::complex<double> coupling,
38  TGraph* phasespace)
39  : _C(coupling), _ps(phasespace)
40  {
41  //_sqrtps= new TGraph(_ps->GetN());
42  //for(int i=0;i<_ps->GetN();++i){
43  // double m,val;
44  // _ps->GetPoint(i,m,val);
45  // _sqrtps->SetPoint(i,m,sqrt(val));
46  //}
47  }
48 
49  //~pwachannel(){if(_sqrtps!=NULL)delete _sqrtps;}
50 
51  pwachannel(const rpwa::pwachannel& ch);
52 
53  // accessors
54  std::complex<double> C() const {return _C;}
55  std::complex<double> CsqrtPS(double m) const {return _C*sqrt(_ps->Eval(m));}
56 
57  TGraph* ps() const {return _ps;}
58  double ps(double m) const {return _ps->Eval(m);}
59 
60  //modifiers
61  void setCoupling(std::complex<double> c){_C=c;}
62 
63 
64  private:
65  std::complex<double> _C;
66  TGraph* _ps;
67  TGraph* _sqrtps;
68  };
69 
70 
71  class pwacomponent {
72  public:
73  pwacomponent(const std::string& name,
74  double m0, double gamma,
75  const std::map<std::string,pwachannel >& channels);
76 
77  virtual ~pwacomponent(){}
78 
79  std::string name() const {return _name;}
80  virtual std::complex<double> val(double m) const ;
81  virtual void setPar(double m0, double gamma){_m0=m0;_m02=m0*m0;_gamma=gamma;}
82  unsigned int numChannels() const {return _channels.size();}
83  const std::string& getChannelName(unsigned int i) const {return _channelname[i];}
84  const pwachannel& getChannel(unsigned int i) const {return *_vchannels[i];}
85  unsigned int numPar() const {return numChannels()*2+2;}
86  void setCouplings(const double* par);
87  void getCouplings(double* par);
88  void setLimits(double mmin, double mmax, double gmin, double gmax)
89  {_m0min=mmin;_m0max=mmax;_gammamin=gmin;_gammamax=gmax;}
90  void setFixed(bool mflag=true, bool gflag=true)
91  {_fixm=mflag;_fixgamma=gflag;}
92  void setConstWidth(bool flag=true){_constWidth=flag;}
93  void getLimits(double& mmin, double& mmax, double& gmin, double& gmax)const
94  {mmin=_m0min;mmax=_m0max;gmin=_gammamin;gmax=_gammamax;}
95  bool fixM() const {return _fixm;}
96  bool fixGamma() const {return _fixgamma;}
97  bool constWidth() const {return _constWidth;}
98 
99  double m0() const {return _m0;}
100  double gamma() const {return _gamma;}
101  const std::map<std::string,pwachannel >& channels()const {return _channels;}
102 
103  friend std::ostream& operator<< (std::ostream& o,const rpwa::pwacomponent& c);
104 
105  protected:
106  std::string _name;
107  double _m0;
108  double _m02;
109  double _m0min,_m0max;
110  double _gamma;
112  bool _fixm;
113  bool _fixgamma;
115  std::map<std::string,pwachannel > _channels;
116  std::vector<pwachannel*> _vchannels; // vector of channels
117  std::vector<std::string> _channelname;
118 
119  };
120 
121 
122  class pwabkg : public pwacomponent{
123  public:
124  pwabkg(const std::string& name,
125  double m0, double gamma,
126  const std::map<std::string,pwachannel >& channels)
127  : pwacomponent(name,m0,gamma,channels){}
128 
129  virtual ~pwabkg(){}
130 
131  virtual std::complex<double> val(double m) const ;
132 
133  void setIsobars(double m1,double m2){_m1=m1;_m2=m2;}
134  void getIsobars(double& m1, double& m2){m1=_m1;m2=_m2;}
135 
136  private:
137  // isobar masses
138  double _m1;
139  double _m2;
140 
141  };
142 
143 
144  class pwacompset {
145  public:
148 
149  void add(pwacomponent* comp){_comp.push_back(comp);_numpar+=comp->numPar();}
150  void setPS(TF1* fPS);
151  void doMapping(); // necessary for performance. to be called after all
152  // components have been added
153 
154 
155  unsigned int n() const {return _comp.size();}
156  unsigned int numPar() const {return _numpar;}
157 
158  std::vector<std::string> wavelist()const;
159 
160  void setPar(const double* par); // set parameters
161  void getPar(double* par); // return parameters
162  unsigned int nFreePSPar() const {return _freePSpar.size();}
163  double getFreePSPar(unsigned int i) const;
164  void getFreePSLimits(unsigned int i, double& lower, double& upper) const;
165 
166 
167  const pwacomponent* operator[](unsigned int i) const {return _comp[i];}
168  std::vector<std::pair<unsigned int,unsigned int> >
169  getCompChannel(const std::string& wave) const;
170 
171 
172  friend std::ostream& operator<< (std::ostream& o,const rpwa::pwacompset& cs);
173  double ps(double m);
174  double intensity(const std::string& wave, double m);
175  double phase(const std::string& wave, double m);
176  double phase(const std::string& wave1,
177  const std::string& wave2,
178  double m);
179  std::complex<double> overlap(const std::string& wave1,
180  const std::string& wave2,
181  double m);
182  std::complex<double> overlap(unsigned int wave1,
183  unsigned int wave2,
184  double m);
185 
186  private:
187  std::vector<pwacomponent*> _comp;
188  unsigned int _numpar;
190  std::vector<unsigned int> _freePSpar; // parameters of phase space to keep floating
191  // mapping for wave -> which components with which channel
192  // wavelist in same order as given by wavelist
193  std::vector<std::vector<std::pair<unsigned int,unsigned int> > > _compChannel;
194 
195 
196  };
197 
198 
199 
200 
201 } // end namespace
202 
203 
204 
205 #endif
206 
207 //--------------------------------------------------------------
208 // $Log$
209 //--------------------------------------------------------------