MINT2
DalitzMCIntegrator.h
Go to the documentation of this file.
1 #ifndef DALITZ_MC_INTEGRATOR_HH
2 #define DALITZ_MC_INTEGRATOR_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:18:02 GMT
5 
8 
10 
11 #include "Mint/IDalitzEvent.h"
13 
14 #include "TRandom.h"
15 
16 #include "Mint/IEventGenerator.h"
17 
18 #include "Mint/DalitzHistoSet.h"
21 
22 /*
23  WARNING: This piece of code is much slower and less accurate than
24  "FastAmplitudeIntegrator", as used by DalitzPdfBaseFastInteg.
25  Still, keep the code for x-checks.
26  */
27 
28 class DalitzMCIntegrator : virtual public IDalitzIntegrator{
29 
30 
31  class integrationWeight : public MINT::IReturnRealForEvent<IDalitzEvent>{
33  public:
36  double RealVal(IDalitzEvent& evt);
37  };
38 
39  long int _Ncalls;
40  double _sumT;
41 
42  mutable double _mean, _variance;
43  const static int _minEvents=1000;
45  double _weightSum;
46 
48  protected:
54  TRandom* _rnd;
55  double _precision;
56 
57  int updateEventSet(int Nevents);
58  double evaluateSum();
59  int determineNumEvents();
61  int addEvents(int Nevents);
62 
64  public:
66  , MINT::IReturnRealForEvent<IDalitzEvent>* weightFunction=0
67  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
68  , TRandom* rnd = gRandom
69  , double precision = 1.e-2
70  );
72 
73  bool initialise(const DalitzEventPattern& pattern
74  , MINT::IReturnRealForEvent<IDalitzEvent>* weightFunction=0
75  , MINT::IEventGenerator<IDalitzEvent>* eventGenerator=0
76  , TRandom* rnd = gRandom
77  , double precision = 1.e-2
78  );
79 
81  weightFunction = 0
82  );
83 
84  void setPrecision(double prec){
85  _precision=prec;
86  if(initialised()){
88  }
89  }
90 
91  // warning - this will not re-evaluate the #events needed for
92  // the precision etc.
93 
94  bool initialised() const{
95  return _initialised;
96  }
97 
98  double getVal();
99 
100  double RealVal(){
101  return getVal();
102  }
103 
105  const MINT::MinuitParameterSet* getMPS() const;
106 
107  virtual void doFinalStats(MINT::Minimiser* mini=0);
108 
110  double den= getVal();
111  den *= _weightSum;
112  if(den <= 0) den=1;
113  return _eventPtrList.reWeightedHistoSet(&_iw)/den;
114  }
115 
116  virtual ~DalitzMCIntegrator(){};
117 
118 };
119 #endif
120 //
MINT::IEventGenerator< IDalitzEvent > * _generator
static const int _minEvents
bool initialised() const
void setPrecision(double prec)
MINT::MinuitParameterSet * getMPS()
integrationWeight(MINT::IReturnRealForEvent< IDalitzEvent > *externalPdf)
DalitzHistoSet histoSet()
bool initialise(const DalitzEventPattern &pattern, MINT::IReturnRealForEvent< IDalitzEvent > *weightFunction=0, MINT::IEventGenerator< IDalitzEvent > *eventGenerator=0, TRandom *rnd=gRandom, double precision=1.e-2)
MINT::IReturnRealForEvent< IDalitzEvent > * _w
MINT::MinuitParameterSet * _mps
MINT::IReturnRealForEvent< IDalitzEvent > * _externalPdf
integrationWeight _iw
int addEvents(int Nevents)
DalitzEventPattern _pat
DalitzEventPtrList _eventPtrList
int updateEventSet(int Nevents)
void setWeight(MINT::IReturnRealForEvent< IDalitzEvent > *pdf)
virtual void doFinalStats(MINT::Minimiser *mini=0)
DalitzHistoSet reWeightedHistoSet(MINT::IReturnRealForEvent< IDalitzEvent > *w)
bool resetIntegrand(MINT::IReturnRealForEvent< IDalitzEvent > *weightFunction=0)