MINT2
FlexiFastAmplitudeIntegrator.h
Go to the documentation of this file.
1 #ifndef FLEXI_FAST_AMPLITUDE_INTEGRATOR_HH
2 #define FLEXI_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 
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;
38 
41 
42  bool _db;
43  protected:
44 
45  //DiskResidentEventList _fastFlexiEventList;
47 
50  //MINT::counted_ptr<IGetDalitzEvent> _weight; // for efficiencies etc
51  // FitAmpPairList _ampList;
52  //MINT::counted_ptr<IIntegrationCalculator> _integCalc;
53  //MINT::counted_ptr<IIntegrationCalculator> _integCalc_copyForDebug;
54  // MINT::counted_ptr<IntegCalculator> _integCalc;
56  // MINT::counted_ptr<IntegCalculator> _integCalc_copyForDebug;
58 
59  TRandom* _rnd;
61  double _precision;
62 
63  void forcedReIntegrate();
64  void reIntegrate();
65 
66  double weight(IDalitzEvent* evtPtr);
67 
68  int updateEventSet(long int Nevents);
69  double evaluateSum();
70  int determineNumEvents();
72 
73  void addEvent(IDalitzEvent& evt);
74  // void reAddEvent(DalitzEvent evt);
75  void reAddEvent(DalitzEvent& evt);
76 
77  int addEvents(long int Nevents);
78 
79  TRandom* makeNewRnd(int seed=-9999);
81  public:
82  FlexiFastAmplitudeIntegrator(const std::string& fastFlexiEventFileName="fastFlexiEventFileName.root");
83 
85  , IFastAmplitudeIntegrable* amps=0
87  eventGenerator=0
88  , TRandom* rnd = 0
89  , double precision = 1.e-2
90  , const std::string& fastFlexiEventFileName="fastFlexiEventFileName.root"
91  );
92 
93  bool initialise(const DalitzEventPattern& pattern
94  , IFastAmplitudeIntegrable* amps=0
95  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
96  , TRandom* rnd = 0
97  , double precision = 1.e-2
98  );
99 
100  /* this is too risky until I save the fit parameter values with the file
101  bool initialiseFromFile(const DalitzEventPattern& pattern
102  , IFastAmplitudeIntegrable* amps
103  , const std::string& commaSeparatedList
104  );
105  */
106 
107  virtual bool add(const FlexiFastAmplitudeIntegrator& other);
108 
109  bool setValues(const DalitzEventPattern& pattern
110  , IFastAmplitudeIntegrable* amps=0
111  //, MINT::counted_ptr<IGetDalitzEvent> weight=0
112  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
113  , TRandom* rnd = 0
114  , double precision = 1.e-2
115  );
116 
117  void setPrecision(double prec){
118  _precision=prec;
119  if(initialised()){
121  }
122  }
123 
124  // warning - this will not re-evaluate the #events needed for
125  // the precision etc.
126 
127  bool initialised() const{
128  return _initialised;
129  }
130 
131  double getVal();
132 
133  double RealVal(){
134  return getVal();
135  }
136 
137  double integralForMatchingPatterns(bool match,int pattern_sign){
138  return _integCalc->integralForMatchingPatterns(match, pattern_sign);
139  }
140 
141  std::complex<double> ComplexIntegralForTags(int tag1, int tag2){
142  return _integCalc->ComplexIntegralForTags(tag1,tag2);
143  }
144 
145  std::complex<double> ComplexSumForMatchingPatterns(bool match){
147  }
148 
151  }
152 
153  double sumOfFitFractions() {
154  return _integCalc->sumOfFitFractions();
155  }
156 
159  }
160 
163  }
164 
167  }
168 
171  bool doFractions() {return _integCalc->doFractions();}
172 
173  double variance() const;
174 
175  DalitzHistoSet histoSet() const;
176  void saveEachAmpsHistograms(const std::string& prefix) const;
177  std::vector<DalitzHistoSet> GetEachAmpsHistograms();
178 
180  void saveInterferenceHistograms(const std::string& prefix) const;
181  std::vector<DalitzHistoSet> GetInterferenceHistograms();
182 
183  virtual void doFinalStats(MINT::Minimiser* mini=0);
184  void doFinalStatsAndSave(MINT::Minimiser* min=0,const std::string& fname = "FitAmpResults.txt", const std::string& fnameROOT="fitFractions.root");
185 
186  double getFractionChi2()const;
187 
188  bool ensureFreshEvents();
189 
190 
191 
192  // bool save(const std::string& fname)const;
193 
194 };
195 #endif
196 //
MINT::counted_ptr< FitAmpPairList > _integCalc
int numberOfFitFractionsLargerThanThreshold(double threshold)
std::complex< double > ComplexIntegralForTags(int tag1, int tag2) const
std::complex< double > ComplexIntegralForTags(int tag1, int tag2)
std::complex< double > ComplexSumForMatchingPatterns(bool match)
FlexiFastAmplitudeIntegrator(const std::string &fastFlexiEventFileName="fastFlexiEventFileName.root")
std::vector< DalitzHistoSet > GetInterferenceHistograms()
double integralForMatchingPatterns(bool match, int pattern_sign) const
bool setValues(const DalitzEventPattern &pattern, IFastAmplitudeIntegrable *amps=0, MINT::IEventGenerator< IDalitzEvent > *eventGenerator=0, TRandom *rnd=0, double precision=1.e-2)
bool initialise(const DalitzEventPattern &pattern, IFastAmplitudeIntegrable *amps=0, MINT::IEventGenerator< IDalitzEvent > *eventGenerator=0, TRandom *rnd=0, double precision=1.e-2)
std::complex< double > ComplexSumForMatchingPatterns(bool match) const
void doFinalStatsAndSave(MINT::Minimiser *min=0, const std::string &fname="FitAmpResults.txt", const std::string &fnameROOT="fitFractions.root")
int numberOfFitFractionsLargerThanThreshold(double threshold)
MINT::IEventGenerator< IDalitzEvent > * _generator
FitFractionList getInterferenceTerms() const
double sumOfFitFractions()
void saveEachAmpsHistograms(const std::string &prefix) const
double integralForMatchingPatterns(bool match, int pattern_sign)
virtual void doFinalStats(MINT::Minimiser *mini=0)
MINT::counted_ptr< TRandom > _localRnd
FitFractionList getFractions() const
virtual bool add(const FlexiFastAmplitudeIntegrator &other)
void saveInterferenceHistograms(const std::string &prefix) const
MINT::counted_ptr< FitAmpPairList > _integCalc_copyForDebug
FitFractionList getInterferenceTerms() const
double sumOfSqrtFitFractions()
double absSumOfSqrtInterferenceFractions()
double absSumOfInterferenceFractions()
std::vector< DalitzHistoSet > GetEachAmpsHistograms()