MINT2
FastAmplitudeIntegrator.h
Go to the documentation of this file.
1 #ifndef FAST_AMPLITUDE_INTEGRATOR_HH
2 #define FAST_AMPLITUDE_INTEGRATOR_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:18:02 GMT
5 
7 
9 
10 #include "Mint/DalitzEvent.h"
11 #include "Mint/DalitzEventList.h"
12 
13 #include "TRandom.h"
14 
15 #include "Mint/IEventGenerator.h"
16 
19 #include "Mint/IntegCalculator.h"
20 
21 #include "Mint/DalitzHistoSet.h"
22 #include "Mint/counted_ptr.h"
23 
24 #include <vector>
25 
26 class FitAmpSum;
27 class IDalitzEvent;
28 
29 namespace MINT{
30  class Minimiser;
31 }
33  mutable double _mean;
34  const static long int _minEvents=100;
36  int _Ncalls;
37 
39 
40  bool _db;
41  protected:
42 
45  //MINT::counted_ptr<IGetDalitzEvent> _weight; // for efficiencies etc
46  // FitAmpPairList _ampList;
47  //MINT::counted_ptr<IIntegrationCalculator> _integCalc;
48  //MINT::counted_ptr<IIntegrationCalculator> _integCalc_copyForDebug;
51 
52  TRandom* _rnd;
54  double _precision;
55 
56  double weight(IDalitzEvent* evtPtr);
57 
58  int updateEventSet(long int Nevents);
59  double evaluateSum();
60  int determineNumEvents();
62  int addEvents(long int Nevents);
63 
64  TRandom* makeNewRnd(int seed=-9999);
66  public:
68 
70  , IFastAmplitudeIntegrable* amps=0
71  //, MINT::counted_ptr<IGetDalitzEvent> weight=0
73  eventGenerator=0
74  , TRandom* rnd = 0
75  , double precision = 1.e-2
76  );
77 
80  , const std::string& fname
81  );
82 
84 
85  bool initialise(const DalitzEventPattern& pattern
86  , IFastAmplitudeIntegrable* amps=0
87  //, MINT::counted_ptr<IGetDalitzEvent> weight=0
88  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
89  , TRandom* rnd = 0
90  , double precision = 1.e-2
91  );
92  bool initialise(const std::string& commaSeparatedList
93  , const DalitzEventPattern& pattern
94  , IFastAmplitudeIntegrable* amps=0
95  //, MINT::counted_ptr<IGetDalitzEvent> weight=0
96  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
97  , TRandom* rnd = 0
98  , double precision = 1.e-2
99  );
100  bool initialiseFromFile(const DalitzEventPattern& pattern
102  , const std::string& commaSeparatedList
103  );
104 
105  virtual bool add(const FastAmplitudeIntegrator& other);
106 
107  bool setValues(const DalitzEventPattern& pattern
108  , IFastAmplitudeIntegrable* amps=0
109  //, MINT::counted_ptr<IGetDalitzEvent> weight=0
110  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
111  , TRandom* rnd = 0
112  , double precision = 1.e-2
113  );
114 
115  void setPrecision(double prec){
116  _precision=prec;
117  if(initialised()){
119  }
120  }
121 
122  // warning - this will not re-evaluate the #events needed for
123  // the precision etc.
124 
125  bool initialised() const{
126  return _initialised;
127  }
128 
129  double getVal();
130  void Gradient(MINT::MinuitParameterSet* mps, std::vector<double>& grad){
131  _integCalc->Gradient(mps,grad);
132  }
133  void GradientForLasso(MINT::MinuitParameterSet* mps, std::vector<double>& grad){
134  _integCalc->GradientForLasso(mps,grad);
135  }
136 
137  double RealVal(){
138  return getVal();
139  }
140 
141  double sumOfFitFractions() {
142  return _integCalc->sumOfFitFractions();
143  }
144 
147  }
148 
151  }
152 
155  }
156 
159  }
160 
161  double variance() const;
162 
163  DalitzHistoSet histoSet() const;
164  void saveEachAmpsHistograms(const std::string& prefix) const;
165  std::vector<DalitzHistoSet> GetEachAmpsHistograms();
166 
168  void saveInterferenceHistograms(const std::string& prefix) const;
169  std::vector<DalitzHistoSet> GetInterferenceHistograms();
170 
171  virtual void doFinalStats(MINT::Minimiser* mini=0);
172  double getFractionChi2()const;
173 
174  bool ensureFreshEvents();
175 
176  bool save(const std::string& fname)const;
177 
178 };
179 #endif
180 //
std::vector< DalitzHistoSet > GetInterferenceHistograms()
void saveEachAmpsHistograms(const std::string &prefix) const
MINT::IEventGenerator< IDalitzEvent > * _generator
MINT::counted_ptr< IntegCalculator > _integCalc_copyForDebug
int numberOfFitFractionsLargerThanThreshold(double threshold)
bool initialise(const DalitzEventPattern &pattern, IFastAmplitudeIntegrable *amps=0, MINT::IEventGenerator< IDalitzEvent > *eventGenerator=0, TRandom *rnd=0, double precision=1.e-2)
bool initialiseFromFile(const DalitzEventPattern &pattern, IFastAmplitudeIntegrable *amps, const std::string &commaSeparatedList)
void GradientForLasso(MINT::MinuitParameterSet *mps, std::vector< double > &grad)
virtual void Gradient(MINT::MinuitParameterSet *mps, std::vector< double > &grad)
double sumOfSqrtFitFractions()
virtual bool add(const FastAmplitudeIntegrator &other)
bool setValues(const DalitzEventPattern &pattern, IFastAmplitudeIntegrable *amps=0, MINT::IEventGenerator< IDalitzEvent > *eventGenerator=0, TRandom *rnd=0, double precision=1.e-2)
DalitzHistoSet histoSet() const
MINT::counted_ptr< TRandom > _localRnd
IFastAmplitudeIntegrable * _amps
bool save(const std::string &fname) const
virtual void doFinalStats(MINT::Minimiser *mini=0)
double absSumOfSqrtInterferenceFractions()
double absSumOfInterferenceFractions()
TRandom * makeNewRnd(int seed=-9999)
virtual void GradientForLasso(MINT::MinuitParameterSet *mps, std::vector< double > &grad)
std::vector< DalitzHistoSet > GetEachAmpsHistograms()
static const long int _minEvents
int updateEventSet(long int Nevents)
MINT::counted_ptr< IntegCalculator > _integCalc
double weight(IDalitzEvent *evtPtr)
DalitzHistoSet interferenceHistoSet() const
void Gradient(MINT::MinuitParameterSet *mps, std::vector< double > &grad)
void saveInterferenceHistograms(const std::string &prefix) const
int numberOfFitFractionsLargerThanThreshold(double threshold)