MINT2
SignalGenerator.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:59 GMT
3 #include "Mint/SignalGenerator.h"
4 #include <ctime>
5 #include <iostream>
6 #include <complex>
7 
8 using namespace std;
9 using namespace MINT;
10 
12  , TRandom* rnd
13  )
14  : BaseGenerator(rnd)
15  , _pat(pat)
16  , _myOwnPSet()
17  , _counted_amps(new FitAmpSum(pat, myMPS()))
18  , _amps(_counted_amps.get())
19  , _boxes(_amps->makeEventGenerator(pat))
20 {
21  _boxes->setRnd(rnd);
22 }
24  , double rB
25  , double phase
26  , TRandom* rnd
27  )
28  : BaseGenerator(rnd)
29  , _pat(pat)
30  , _myOwnPSet()
31  , _counted_amps(0)
32  , _amps(0)
33  , _boxes(0)
34 {
35  DalitzEventPattern cpPat(pat);
36  cpPat[0].antiThis();
37 
38  counted_ptr<FitAmpSum> fs(new FitAmpSum(pat, myMPS()));
39  FitAmpSum cpAmps(pat, myMPS());
40  cpAmps *= polar(rB, phase);
41  fs->add(cpAmps);
44 
45  makeBoxes();
46 
47  /*
48  counted_ptr< IUnweightedEventGenerator<IDalitzEvent> >
49  bpt(fs->makeEventGenerator());
50 
51  _boxes = bpt;
52  _boxes->setRnd(_rnd);
53  */
54 }
57  , TRandom* rnd)
58  : BaseGenerator(rnd)
59  , _pat(pat)
60  , _myOwnPSet()
61  , _counted_amps(0)
62  , _amps(amps)
63  , _boxes(_amps->makeEventGenerator(pat))
64 {
65  _boxes->setRnd(_rnd);
66 }
67 
69  // seems like an unnecessary complication
70  // but it's a "hook" to add the option to pass
71  // other MinuitParameterSets to SignalGenerator
72  // should this become necessary.
73  return & _myOwnPSet;
74 }
75 
76 
78  if(0 == _amps) return 0;
81  _boxes = bpt;
82  if(0 == _boxes) return 0;
83  _boxes->setRnd(_rnd);
84  return true;
85 }
86 
88 // bool dbThis=false;
89  if(0 == _boxes) makeBoxes();
90  if(_unWeighted){
92  if(0 != evtPtr) evtPtr->setMothers3Momentum(mothers3Momentum());
93 /* if(dbThis && 0 != evtPtr){
94  cout << "SignalGenerator::tryDalitzEvent(): made un-weighted event "
95  << "with weight " << evtPtr->getWeight() << endl;
96  }*/
97  return evtPtr;
98  }else{
100  if(0 != evtPtr) evtPtr->setMothers3Momentum(mothers3Momentum());
101 // if(dbThis && 0 != evtPtr){
102 // cout << "SignalGenerator::tryDalitzEvent(): made weighted event "
103 // << "with weight " << evtPtr->getWeight() << endl;
104 // }
105  return evtPtr;
106  }
107 }
108 
110 // bool dbThis=false;
111  counted_ptr<IDalitzEvent> evtPtr(0);
112  int counter(0);
113  int largeNumber(1000000);
114 
115  do{
116  evtPtr = tryDalitzEvent();
117  }while(0 == evtPtr && counter++ < largeNumber);
118  if(saveEvents()) _evtList->Add(evtPtr);
119 /* if(dbThis){
120  cout << "SignalGenerator::newDalitzEvent:"
121  << " just generated this event:\n" << *evtPtr << endl;
122  }*/
123  return evtPtr;
124 }
125 
129 }
132 }
133 
135  if(0 == _boxes) return false;
137 
138 }
140  if(0 == _boxes) return false;
142 }
143 //
virtual bool setRnd(TRandom *rnd)=0
MINT::counted_ptr< MINT::IUnweightedEventGenerator< IDalitzEvent > > _boxes
virtual int add(const FitAmpListBase &other, double factor=1)
MINT::counted_ptr< DiskResidentEventList > _evtList
Definition: BaseGenerator.h:31
virtual bool ensureFreshEvents()
TRandom * _rnd
Definition: BaseGenerator.h:37
MINT::MinuitParameterSet _myOwnPSet
virtual MINT::counted_ptr< IDalitzEvent > newEvent()
MINT::counted_ptr< IFastAmplitudeIntegrable > _counted_amps
DalitzEventPattern _pat
bool saveEvents()
Definition: BaseGenerator.h:34
virtual bool Add(const DalitzEvent &evt)
virtual bool ensureFreshEvents()=0
SignalGenerator(const DalitzEventPattern &pat, TRandom *rnd=gRandom)
virtual MINT::counted_ptr< IDalitzEvent > newDalitzEvent()
bool am_I_generating_what_I_think_I_am_generating(int Nevents=100000)
virtual bool am_I_generating_what_I_think_I_am_generating(int)
virtual counted_ptr< RETURN_TYPE > newEvent()=0
IFastAmplitudeIntegrable * _amps
virtual bool ensureFreshEvents()
virtual MINT::counted_ptr< MINT::IUnweightedEventGenerator< IDalitzEvent > > makeEventGenerator(const DalitzEventPattern &pat, TRandom *rnd=gRandom)=0
virtual counted_ptr< RETURN_TYPE > newUnweightedEvent()=0
TVector3 mothers3Momentum() const
virtual MINT::counted_ptr< IDalitzEvent > tryDalitzEvent()
Double_t get(const RooArgList &b, int i)
bool compareGenerationMethodsForFullPDF(int Nevents=100000)
MINT::MinuitParameterSet * myMPS()
X * get() const
Definition: counted_ptr.h:123