MINT2
Model_independent.cpp
Go to the documentation of this file.
3 #include "TMath.h"
4 #include "TCanvas.h"
5 #include "TH2D.h"
6 #include "TGraph.h"
7 #include "Mint/Utils.h"
8 #include "Mint/DalitzEventList.h"
10 #include <cmath>
11 #include <complex>
12 #include <cstdlib>
13 #include "Math/Interpolator.h"
14 #include "Math/InterpolationTypes.h"
15 
16 using namespace std;
17 using namespace MINT;
18 
19 
20 Model_independent::Model_independent( const AssociatedDecayTree& tree, const std::string& namePrefix):
21  BW_BW(tree, namePrefix)
22  , _binCenters("BinCenters_inGeV2")
23  , _interpolationTypeString("MI::InterpolationType",(std::string)"kCSPLINE")
24  , _interpolationType(ROOT::Math::Interpolation::kCSPLINE)
25 {
27  _nBins = _binCenterVector.size();
28  if((string)_interpolationTypeString == "kLINEAR")_interpolationType = ROOT::Math::Interpolation::kLINEAR;
29  if((string)_interpolationTypeString == "kPOLYNOMIAL")_interpolationType = ROOT::Math::Interpolation::kPOLYNOMIAL;
30  if((string)_interpolationTypeString == "kAKIMA")_interpolationType = ROOT::Math::Interpolation::kAKIMA;
31  if((string)_interpolationTypeString == "kCSPLINE_PERIODIC")_interpolationType = ROOT::Math::Interpolation::kCSPLINE_PERIODIC;
32  if((string)_interpolationTypeString == "kAKIMA_PERIODIC")_interpolationType = ROOT::Math::Interpolation::kAKIMA_PERIODIC;
33 
34  vector<double> binCenterValues_Re = getBinCenterValues_Re();
35  vector<double> binCenterValues_Im = getBinCenterValues_Im();
36  _interpolator_Re = new ROOT::Math::Interpolator(_binCenterVector, binCenterValues_Re, _interpolationType);
37  _interpolator_Im = new ROOT::Math::Interpolator(_binCenterVector, binCenterValues_Im, _interpolationType);
38 }
39 
41  vector<double> vec;
42  for (int i= 0; i<_nBins; i++) {
43  vec.push_back(Re_Bin(i));
44  }
45  return vec;
46 }
47 
49  vector<double> vec;
50  for (int i= 0; i<_nBins; i++) {
51  vec.push_back(Im_Bin(i));
52  }
53  return vec;
54 }
55 
56 std::complex<double> Model_independent::getVal(IDalitzEvent& evt){
57  setEventPtr(evt);
59 
60  double formFactor= 1.;
61  if( _normBF == 1 ) formFactor = Fr();
62  else if( _normBF == 0 ) formFactor = Fr_PDG_BL();
63  else if(_normBF == 2 ) formFactor = Fr_BELLE(0.);
64 
65  return formFactor*getInterpolatedVal(mumsRecoMass2()/(GeV*GeV));
66 }
67 
68 std::complex<double> Model_independent::getInterpolatedVal(const double s_inGeV2){
69 
70  if(_binCenterVector[0]>s_inGeV2)return 0;
71  if(_binCenterVector[_nBins-1]<s_inGeV2)return 0;
72 
73  vector<double> binCenterValues_Re = getBinCenterValues_Re();
74  vector<double> binCenterValues_Im = getBinCenterValues_Im();
75 
77  delete _interpolator_Re;
78  delete _interpolator_Im;
79  _interpolator_Re = new ROOT::Math::Interpolator(_binCenterVector, binCenterValues_Re, _interpolationType);
80  _interpolator_Im = new ROOT::Math::Interpolator(_binCenterVector, binCenterValues_Im, _interpolationType);
81  }
82  return complex<double>(_interpolator_Re->Eval(s_inGeV2),_interpolator_Im->Eval(s_inGeV2));
83 }
84 
85 
87 
88  TCanvas* c = new TCanvas();
89 
90  int n = _nBins;
91  vector<double> binCenterValues_Re = getBinCenterValues_Re();
92  vector<double> binCenterValues_Im = getBinCenterValues_Im();
93 
94  std::vector<double> Re(n), Im(n), mag(n), phase(n), delta(n), mass2(n);
95 
96  for (int i=0; i<n; i++) {
97  Re[i] = binCenterValues_Re[i] ;
98  Im[i] = binCenterValues_Im[i] ;
99  mag[i] = pow(binCenterValues_Re[i],2) + pow(binCenterValues_Im[i],2);
100  delta[i] = 1./2. * atan( (binCenterValues_Im[i] - 1./2.)/binCenterValues_Re[i] ) + TMath::Pi() / 4.;
101  phase[i] = arg(complex<double>(Re[i],Im[i]) );
102  mass2[i] = _binCenterVector[i];
103  }
104 
105  double m2_start = _binCenterVector[0];
106  double step = 0.01;
107  int nSteps = ( (_binCenterVector[n-1]) - m2_start)/step;
108  std::vector<double> Re_itp(nSteps), Im_itp(nSteps), mag_itp(nSteps), phase_itp(nSteps), delta_itp(nSteps), mass2_itp(nSteps);
109 
110  for(int i=0; i<nSteps; i++){
111  mass2_itp[i] = m2_start + i * step;
112  Re_itp[i] = getInterpolatedVal(mass2_itp[i]).real();
113  Im_itp[i] = getInterpolatedVal(mass2_itp[i]).imag() ;
114  mag_itp[i] = pow(Re_itp[i],2) + pow(Im_itp[i],2);
115  phase_itp[i] = arg(complex<double>(Re_itp[i],Im_itp[i]) );
116  delta_itp[i] = 1./2. * atan( (Im_itp[i] - 1./2.)/Re_itp[i] ) + TMath::Pi() / 4.;
117  }
118 
119  TGraph* g = new TGraph(n,&Re[0],&Im[0]);
120  g->SetTitle("Argand; Re(A) ; Im(A)");
121  TGraph* g_itp = new TGraph(nSteps,&Re_itp[0],&Im_itp[0]);
122  g_itp->SetLineColor(kRed);
123  g->Draw("A*");
124  g_itp->Draw("Csame");
125  c->Print(("argand_"+anythingToString(mumsPID())+".eps").c_str());
126  delete g;
127  delete g_itp;
128 
129  g = new TGraph(n,&mass2[0],&mag[0]);
130  g->SetTitle(" ; s[GeV^{2}] ; |A|^{2}");
131  g_itp = new TGraph(nSteps,&mass2_itp[0],&mag_itp[0]);
132  g_itp->SetLineColor(kRed);
133  g->Draw("A*");
134  g_itp->Draw("Csame");
135  c->Print(("mag_"+anythingToString(mumsPID())+".eps").c_str());
136  delete g;
137  delete g_itp;
138 
139  g = new TGraph(n,&mass2[0],&phase[0]);
140  g->SetTitle(" ; s[GeV^{2}] ; arg(A)");
141  g_itp = new TGraph(nSteps,&mass2_itp[0],&phase_itp[0]);
142  g_itp->SetLineColor(kRed);
143  g->Draw("A*");
144  g_itp->Draw("Csame");
145  c->Print(("phase_"+anythingToString(mumsPID())+".eps").c_str());
146  delete g;
147  delete g_itp;
148 
149  g = new TGraph(n,&mass2[0],&delta[0]);
150  g->SetTitle(" ; s[GeV^{2}] ; #delta(A)");
151  g_itp = new TGraph(nSteps,&mass2_itp[0],&delta_itp[0]);
152  g_itp->SetLineColor(kRed);
153  g->Draw("A*");
154  g_itp->Draw("Csame");
155  c->Print(("delta_"+anythingToString(mumsPID())+".eps").c_str());
156  delete g;
157  delete g_itp;
158 }
159 
160 
161 //
virtual bool changedSinceLastCall() const
virtual void resetInternals()
Definition: BW_BW.cpp:1114
virtual double Fr()
Definition: BW_BW.cpp:710
std::vector< double > getBinCenterValues_Im()
NamedParameter< std::string > _interpolationTypeString
bool setEventPtr(IDalitzEvent &evt) const
Definition: BW_BW.cpp:141
ROOT::Math::Interpolator * _interpolator_Re
virtual std::complex< double > getVal(IDalitzEvent &evt)
virtual int mumsPID() const
Definition: BW_BW.cpp:517
Model_independent(const AssociatedDecayTree &tree, const std::string &namePrefix="")
Definition: BW_BW.h:30
std::complex< double > getInterpolatedVal(const double s_inGeV2)
virtual double Fr_PDG_BL()
Definition: BW_BW.cpp:830
double Re_Bin(int i) const
std::vector< double > getBinCenterValues_Re()
virtual double mumsRecoMass2() const
Definition: BW_BW.cpp:548
std::vector< double > _binCenterVector
NamedParameter< double > _binCenters
const std::vector< T > & getVector() const
ROOT::Math::Interpolator * _interpolator_Im
MINT::NamedParameter< int > _normBF
Definition: BW_BW.h:66
static const double GeV
std::string anythingToString(const T &anything)
Definition: Utils.h:62
virtual double Fr_BELLE(double prSquared)
Definition: BW_BW.cpp:720
double Im_Bin(int i) const
static const double g
ROOT::Math::Interpolation::Type _interpolationType