MINT2
AmpsPdfFlexiFastCPV.h
Go to the documentation of this file.
1 #ifndef __AMPSFLEXIFASTCPV_H__
2 #define __AMPSFLEXIFASTCPV_H__
3 
4 #include <Mint/PdfBase.h>
5 #include <Mint/IDalitzPdf.h>
6 #include <Mint/IDalitzEvent.h>
7 #include <Mint/FitParameter.h>
9 #include <iostream>
10 #include <complex>
11 
12 // Time-dependent PDF
13 class AmpsPdfFlexiFastCPV : public MINT::PdfBase<IDalitzEvent>
14 , virtual public IDalitzPdf{
15 
16 protected:
20 
24 
30 
31  double _intA;
32  double _intAbar;
33  std::complex<double> _intAAbar;
34 
35 public:
41  }
42  void beginFit(){
43  _ampsSum->beginFit();
45  }
46  void endFit(){
48  _ampsSum->endFit();
49  }
50 
52  std::cout << "intSum = " << _ampsSum->getIntegralValue() << std::endl;
53  std::cout << "intA = " << _intA << std::endl;
54  std::cout << "intAbar = " << _intAbar << std::endl;
55  std::cout << "intAAbar = " << _intAAbar.real() << std::endl;
56  }
57 
58  inline double un_normalised_noPs(IDalitzEvent& evt){
59  const double t = (double) evt.getValueFromVector(0);
60  const double dt = (double) evt.getValueFromVector(1);
61  const double q = static_cast<double>((int)evt.getValueFromVector(2));
62  const double w = (double) evt.getValueFromVector(3);
63  const double f = static_cast<double>((int)evt.getValueFromVector(4));
64 
65  const double e_eff = fabs(q)*_eff_tag + (1.-fabs(q))*(1.-_eff_tag);
66 
67  double r = (double)_r; // * sqrt(_intA/_intAbar);
68  const std::complex<double> phase_diff = std::polar((double)r,((double) _delta -(double)_gamma*f)/360.*2*pi);
69 
70  const std::complex<double> amp = _amps1->ComplexVal_un_normalised_noPs(evt) ;
71  const std::complex<double> amp_bar = _amps2->ComplexVal_un_normalised_noPs(evt) * phase_diff;
72 
73  const double val = exp(-fabs(t)/(double)_tau) *
74  (
75  (2.-fabs(q))*(norm(amp) + norm(amp_bar))*cosh((double)_dGamma/2.*t)
76  +f*q*(1.-2.*w)*(norm(amp) - norm(amp_bar)) *cos((double)_dm*t)
77  -(2.-fabs(q))*2.0*real(amp_bar*conj(amp))*sinh((double)_dGamma/2.*t)
78  -f*2.0*q*(1.-2.*w)*imag(amp_bar*conj(amp))*sin((double)_dm*t)
79  )*e_eff;
80 
81  return val;
82  }
83 
84  virtual double getVal(IDalitzEvent& evt){
85 
86  const double f = static_cast<double>((int)evt.getValueFromVector(4));
87  const double val = un_normalised_noPs(evt);
88 
89  double r = (double)_r; // * sqrt(_intA/_intAbar);
90  const double Gamma = 1./((double) _tau);
91  const std::complex<double> phase_diff = std::polar((double)r,((double) _delta -(double)_gamma*f)/360.*2*pi);
92  const double int_interference = (phase_diff*_intAAbar).real();
93 
94  if(_intA == -1 ){
95  std::cout << "AmpsPdfFlexiFastCPV:: _norm = -1, should not have happened." << std::endl;
96  throw "can't deal with that";
97  }
98 
99  return val/(2.* ((_intA + r* r * _intAbar) * 4.*Gamma - int_interference * 2. * _dGamma )/ (4.*Gamma*Gamma-_dGamma*_dGamma));
100  }
101 
102  virtual double getVal_withPs(IDalitzEvent& evt){return getVal(evt);}
103  virtual double getVal_noPs(IDalitzEvent& evt){return getVal(evt);}
104 
105  virtual double getVal(IDalitzEvent* evt){
106  if(0 == evt) return 0;
107  return getVal(*evt);
108  }
109  virtual double getVal_withPs(IDalitzEvent* evt){
110  if(0 == evt) return 0;
111  return getVal_withPs(*evt);
112  }
113  virtual double getVal_noPs(IDalitzEvent* evt){
114  if(0 == evt) return 0;
115  return getVal_noPs(*evt);
116  }
117 
118  virtual DalitzHistoSet histoSet(){return _ampsSum->histoSet();}
119 
120  void doFinalStatsAndSaveForAmp12(MINT::Minimiser* min=0,const std::string& fname = "FitAmpResults",
121  const std::string& fnameROOT="fitFractions"){
124  _amps1->doFinalStatsAndSave(min,((std::string)fname+".txt").c_str(),((std::string)fnameROOT+".root").c_str());
125  _amps2->doFinalStatsAndSave(min,((std::string)fname+"_CC.txt").c_str(),((std::string)fnameROOT+"_CC.root").c_str());
126  }
127 
131  MINT::FitParameter& eff_tag, MINT::FitParameter& w ):
132  _amps1(amps1),
133  _amps2(amps2),
134  _ampsSum(ampsSum),
135  _r(r),
136  _delta(delta),
137  _gamma(gamma),
138  _tau(tau),
139  _dGamma(dGamma),
140  _dm(dm),
141  _eff_tag(eff_tag),
142  _w(w),
143  _intA(-1),
144  _intAbar(-1),
145  _intAAbar(-1)
146  {}
147 };
148 
149 
150 #endif
double un_normalised_noPs(IDalitzEvent &evt)
virtual double getVal_noPs(IDalitzEvent &evt)
AmpsPdfFlexiFast * _amps1
std::complex< double > _intAAbar
static const double pi
MINT::FitParameter & _dGamma
AmpsPdfFlexiFast * _ampsSum
MINT::FitParameter & _tau
virtual double getVal_noPs(IDalitzEvent *evt)
MINT::FitParameter & _delta
AmpsPdfFlexiFastCPV(AmpsPdfFlexiFast *amps1, AmpsPdfFlexiFast *amps2, AmpsPdfFlexiFast *ampsSum, MINT::FitParameter &r, MINT::FitParameter &delta, MINT::FitParameter &gamma, MINT::FitParameter &tau, MINT::FitParameter &dGamma, MINT::FitParameter &dm, MINT::FitParameter &eff_tag, MINT::FitParameter &w)
virtual double getVal(IDalitzEvent *evt)
std::complex< double > ComplexSumForMatchingPatterns(bool match)
virtual double getVal_withPs(IDalitzEvent *evt)
virtual double getValueFromVector(unsigned int i) const =0
double integralForMatchingPatterns(bool match, int pattern_sign)
MINT::FitParameter & _dm
virtual DalitzHistoSet histoSet() const
virtual double getVal(IDalitzEvent &evt)
MINT::FitParameter & _eff_tag
std::complex< double > ComplexVal_un_normalised_noPs(IDalitzEvent &evt)
void doFinalStatsAndSaveForAmp12(MINT::Minimiser *min=0, const std::string &fname="FitAmpResults", const std::string &fnameROOT="fitFractions")
AmpsPdfFlexiFast * _amps2
void doFinalStatsAndSave(MINT::Minimiser *min=0, const std::string &fname="FitAmpResults.txt", const std::string &fnameROOT="fitFractions.root")
virtual DalitzHistoSet histoSet()
MINT::FitParameter & _w
MINT::FitParameter & _r
virtual double getVal_withPs(IDalitzEvent &evt)
MINT::FitParameter & _gamma