MINT2
DalitzPdfBaseFastInteg.h
Go to the documentation of this file.
1 #ifndef DALITZ_PDF_BASE_FAST_INTEG_HH
2 #define DALITZ_PDF_BASE_FAST_INTEG_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:18:01 GMT
5 
6 #include "Mint/PdfBase.h"
8 
9 #include "Mint/IEventGenerator.h"
10 #include "Mint/IDalitzEvent.h"
13 #include "Mint/DalitzEvent.h"
15 #include "Mint/DalitzHistoSet.h"
17 
18 #include "Mint/counted_ptr.h"
19 
20 #include <string>
21 #include <vector>
22 
23 //#define CHECK_INTEGRATOR
24 
25 #ifdef CHECK_INTEGRATOR
27 #endif
28 
30 
31 #include "Mint/IDalitzPdf.h"
32 
33 /*
34  As a user, you will need to implement this method:
35 
36  virtual double un_normalised_noPs(IDalitzEvent& evt);
37 
38  it returns the PDF without the phase-space factor,
39  no need for normalisation. Typical implementation if you
40  have a FitAmpSum called _amps:
41 
42  double un_normalised_noPs(IDalitzEvent& evt){
43  return _amps->RealVal(evt);
44  }
45 
46  */
47 
48 namespace MINT{
49  class Minimiser;
50 }
51 
53 : public MINT::PdfBase<IDalitzEvent>
54 , virtual public IDalitzPdf
55 {
56  protected:
59  double _norm;
60  double _precision;
61 #ifdef CHECK_INTEGRATOR
62  DalitzMCIntegrator _mcint;
63 #endif
67  // MINT::counted_ptr<IGetDalitzEvent> _efficiency;
68 
72 
74  double _val;
75  std::vector<double> _gradNorm;
77 
78  void setup();
79  bool makeAmps();
80 
81  virtual double un_normalised_noPs(IDalitzEvent& evt)=0;
82  // This replaces un_normalised. Make sure it
83  // does not contain the phase space component.
84  // ... turned out that it's important in several
85  // places to separate this out.
86 
87  virtual double phaseSpace(IDalitzEvent& evt);
88  virtual bool getNorm();
89  virtual bool integrating();
90 
92 
93 
95 
96  public:
100  , double precision = 1.e-3
101  , MINT::MinuitParameterSet* mps=0
102  );
103 
106  //, MINT::counted_ptr<IGetDalitzEvent> eff=0
107  , MINT::MinuitParameterSet* mps=0
108  , double precision = 1.e-3
109  );
110 
112 
113  virtual ~DalitzPdfBaseFastInteg();
114 
115  void setIntegrationPrecision(double prec);
119 
120  void parametersChanged();
121  virtual double getVal(IDalitzEvent& evt);
122  virtual double getVal_withPs(IDalitzEvent& evt);
123  virtual double getVal_noPs(IDalitzEvent& evt);
124 
125  virtual double getNewVal(IDalitzEvent& evt){
126  this->parametersChanged();
127  return getVal(evt);
128  };
129 
130  // next 4 for backward compability (will be removed one day):
131  virtual double getVal(IDalitzEvent* evt){
132  if(0 == evt) return 0;
133  return getVal(*evt);
134  }
135  virtual double getVal_withPs(IDalitzEvent* evt){
136  if(0 == evt) return 0;
137  return getVal_withPs(*evt);
138  }
139  virtual double getVal_noPs(IDalitzEvent* evt){
140  if(0 == evt) return 0;
141  return getVal_noPs(*evt);
142  }
143  virtual double getNewVal(IDalitzEvent* evt){
144  this->parametersChanged();
145  if(0 == evt) return 0;
146  return getNewVal(*evt);
147  }
148 
149  virtual void Gradient(IDalitzEvent& evt,std::vector<double>& grad, MINT::MinuitParameterSet* mps);
150  virtual void GradientForLasso(std::vector<double>& grad);
152 
153  virtual double RealVal(IDalitzEvent& evt){return getVal(evt);}
154  // w/o phase space - more robust if your events leak out of
155  // the kinematically allowed region.
156 
158  const MINT::MinuitParameterSet* getMPS() const;
159 
160  bool saveIntegrator(const std::string& fname)const;
161 
162  bool makePlots(const std::string& filename) const;
163 
164  virtual DalitzHistoSet histoSet() const;
165  virtual DalitzHistoSet histoSet();
166  void saveEachAmpsHistograms(const std::string& prefix) const;
167  std::vector<DalitzHistoSet> GetEachAmpsHistograms();
168 
169  virtual DalitzHistoSet interferenceHistoSet() const;
171  void saveInterferenceHistograms(const std::string& prefix) const;
172  std::vector<DalitzHistoSet> GetInterferenceHistograms();
173 
175  //double efficiency(){return _efficiency->RealVal();}
176  virtual void endFit();
177 
178  void setIntegratorFileName(const std::string& commaSeparatedList);
179 
180  double getIntegralValue() const{
181  return _norm;
182  }
184  if(_norm < 0) getNorm(); return _norm;
185  }
186  double redoIntegrator(){
187  _norm = -1;
188  getNorm();
189  return _norm;
190  }
191 
192  double sumOfFitFractions() {
193  if(!_faint.initialised())getNorm();
194  return _faint.sumOfFitFractions();
195  }
196 
198  if(!_faint.initialised())getNorm();
200  }
201 
203  if(!_faint.initialised())getNorm();
205  }
206 
208  if(!_faint.initialised())getNorm();
209  return _faint.sumOfSqrtFitFractions();
210  }
211 
214  }
215 
216  void doFinalStats(MINT::Minimiser* mini=0);
217 };
218 
219 #endif
220 //
MINT::IEventGenerator< IDalitzEvent > * _generator
std::vector< DalitzHistoSet > GetEachAmpsHistograms()
virtual double getVal(IDalitzEvent &evt)
IFastAmplitudeIntegrable * getAmps()
virtual double getVal_withPs(IDalitzEvent *evt)
virtual double getVal_noPs(IDalitzEvent &evt)
MINT::IEventGenerator< IDalitzEvent > * makeDefaultGenerator()
std::vector< DalitzHistoSet > GetInterferenceHistograms()
void setIntegratorFileName(const std::string &commaSeparatedList)
MINT::IEventGenerator< IDalitzEvent > * getEventGenerator()
void saveInterferenceHistograms(const std::string &prefix) const
virtual double getVal(IDalitzEvent *evt)
virtual double getVal_withPs(IDalitzEvent &evt)
void doFinalStats(MINT::Minimiser *mini=0)
IFastAmplitudeIntegrable * getFitAmpSum()
bool saveIntegrator(const std::string &fname) const
void setIntegrationPrecision(double prec)
virtual void Gradient(IDalitzEvent &evt, std::vector< double > &grad, MINT::MinuitParameterSet *mps)
virtual double getVal_noPs(IDalitzEvent *evt)
MINT::counted_ptr< IFastAmplitudeIntegrable > _countedAmps
virtual DalitzHistoSet interferenceHistoSet() const
DalitzPdfBaseFastInteg(const DalitzEventPattern &pat, MINT::IEventGenerator< IDalitzEvent > *generator, IFastAmplitudeIntegrable *amps, double precision=1.e-3, MINT::MinuitParameterSet *mps=0)
virtual DalitzHistoSet histoSet() const
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _defaultGenerator
virtual double un_normalised_noPs(IDalitzEvent &evt)=0
std::string _commaSepList_of_SavedIntegrators
MINT::MinuitParameterSet * _mps
bool makePlots(const std::string &filename) const
virtual double getNewVal(IDalitzEvent &evt)
virtual double RealVal(IDalitzEvent &evt)
IFastAmplitudeIntegrable * _amps
int numberOfFitFractionsLargerThanThreshold(double threshold)
virtual void GradientForLasso(std::vector< double > &grad)
std::vector< double > _gradNorm
MINT::MinuitParameterSet * getMPS()
void saveEachAmpsHistograms(const std::string &prefix) const
virtual double getNewVal(IDalitzEvent *evt)
FastAmplitudeIntegrator _faint
static const double g
virtual double phaseSpace(IDalitzEvent &evt)
void setEventGenerator(MINT::IEventGenerator< IDalitzEvent > *g)
int numberOfFitFractionsLargerThanThreshold(double threshold)