MINT2
DalitzMCMC.cpp
Go to the documentation of this file.
1 // author: Nunya Business (ya.mum@bristol.ac.uk)
2 // status: Mon 19 Dec 2013 19:17:59 GMT
3 
4 #include <iostream>
5 
6 #include "Mint/DalitzMCMC.h"
7 
9  const unsigned int& seed )
10  : _pat(pat)
11  , _nbody(_pat.numDaughters())
12  , _myOwnPSet()
13  , _pdf(_pat, &_myOwnPSet)
14 {
15  //Setup TGenPhaseSpace
16  _P.SetXYZM( 0.0, 0.0, 0.0, _pat[0].mass() );
17 
18  std::vector<double> masses(_nbody);
19  for( unsigned int i=0; i<_nbody; i++ )
20  masses[i] = _pat[i+1].mass();
21 
22  gRandom->SetSeed(seed);
23  _event.SetDecay(_P, _nbody, &masses[0]);
24 }
25 
27  const unsigned int& NEvents )
28 {
29  //Markov Chain
30  double ratio;
31 
32  //Start event
33  DalitzEvent candEvent_start = GetFlatEvent();
34 
35  //Next event
36  DalitzEvent candEvent_next;
37 
38  for( unsigned int i=0; i<NEvents; i++ ){
39  candEvent_next = GetFlatEvent();
40 
41  const double pdf_start = _pdf.Prob(candEvent_start);
42 
43  const double pdf_next = _pdf.Prob(candEvent_next);
44 
45  ratio = pdf_next/pdf_start;
46  if( ratio >= 1.0 ){
47  candEvent_start = candEvent_next;
48  evtList.Add(candEvent_next);
49  }else{
50  const double height = gRandom->Rndm();
51  if( height < ratio ){
52  candEvent_start = candEvent_next;
53  evtList.Add(candEvent_next);
54  }else{
55  evtList.Add(candEvent_start);
56  }
57  }
58  }
59 }
60 
62 {
63  std::vector<TLorentzVector> p4_mumAndDgtr(_nbody+1);
64 
65  //Fill mother momentum
66  p4_mumAndDgtr[0] = _P;
67 
68  //Fill daughter momenta
69  while(true){
70  const double weight = _event.Generate();
71  const double height = gRandom->Uniform(1.0/weight);
72 
73  if( height < 1.0 ){
74  for( unsigned int i=0; i<_nbody; i++ )
75  p4_mumAndDgtr[i+1] = *(_event.GetDecay(i));
76 
77  break;
78  }
79  }
80 
81  const DalitzEvent flatEvent(_pat, p4_mumAndDgtr);
82  return flatEvent;
83 }
84 
85 //
TLorentzVector _P
Definition: DalitzMCMC.h:38
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventList.h:63
DalitzEvent GetFlatEvent()
Definition: DalitzMCMC.cpp:61
virtual double Prob(IDalitzEvent &evt)
Definition: FitAmpSum.h:100
DalitzMCMC(const DalitzEventPattern &pat, const unsigned int &seed=0)
Definition: DalitzMCMC.cpp:8
const DalitzEventPattern _pat
Definition: DalitzMCMC.h:32
FitAmpSum _pdf
Definition: DalitzMCMC.h:36
const unsigned int _nbody
Definition: DalitzMCMC.h:33
TGenPhaseSpace _event
Definition: DalitzMCMC.h:39
void FillEventList(DalitzEventList &evtList, const unsigned int &NEvents)
Definition: DalitzMCMC.cpp:26