17 map<string, unsigned> infoNames ;
25 const double smeareddecaytime) :
41 return getValueFromVector(ITAG) ;
45 setValueInVector(ITAG, tag) ;
49 return getValueFromVector(IDECAYTIME) ;
53 setValueInVector(IDECAYTIME, decaytime) ;
57 return getValueFromVector(ISMEAREDDECAYTIME) ;
61 setValueInVector(ISMEAREDDECAYTIME, decaytime) ;
71 double deltagamma,
double qoverp,
double phi,
72 TRandom3* rndm, TH1F* h_efficiency,
100 double width,
double deltam,
101 double deltagamma,
double qoverp,
double phi,
102 TRandom3* rndm, TH1F* h_efficiency,
105 m_pattern(model->getAmpPtr(0)->getTreePattern()),
106 m_cppattern(cpmodel->getAmpPtr(0)->getTreePattern()),
109 m_bothmodel(*m_model),
110 m_generator(m_pattern, &m_bothmodel),
113 m_deltagamma(deltagamma),
114 m_qoverp(polar(qoverp, phi)),
118 m_h_efficiency(h_efficiency),
120 m_resWidth(resWidth),
121 m_addExpEffects(addExpEffects),
122 m_sEfficiency(sEfficiency)
145 double smeareddecaytime = decaytime ;
149 float efficiency = 0 ;
150 int maxiter = 100000 ;
165 if(
m_rndm->Rndm() < efficiency){
174 cout <<
"WARNING: Decay time generation limit exceeded." << endl ;
179 return pair<double, double>(decaytime, smeareddecaytime) ;
184 double decaytime(0.) ;
185 double smeareddecaytime(0.) ;
190 unsigned maxattempts = 100000 ;
194 tag =
m_rndm->Rndm() > 0.5 ? 1 : -1 ;
200 if( i >= maxattempts)
201 throw range_error(
"Failed to generate an event in 100000 attempts!") ;
209 double decaytime(0.) ;
210 double smeareddecaytime(0.) ;
215 unsigned maxattempts = 100000 ;
219 tag =
m_rndm->Rndm() > 0.5 ? 1 : -1 ;
225 if( i >= maxattempts)
226 throw range_error(
"Failed to generate an event in 100000 attempts!") ;
239 double pdfval =
pdf_value(tag, decaytime, evt) ;
243 cout <<
"pdfval " << pdfval <<
" maxval " << maxval << endl ;
246 cout <<
"scale " <<
m_scale << endl ;
250 if(
m_rndm->Rndm() * maxval < pdfval){
284 complex<double> Amp = coeffs.first * Ap + coeffs.second * Am ;
285 double ampnorm = norm(Amp) ;
298 complex<double> expterm = exp(complex<double>(0.5 *
m_deltagamma * decaytime,
m_deltam * decaytime)) ;
299 complex<double> plusterm = 1. + expterm ;
300 complex<double> minusterm = 1. - expterm ;
301 complex<double> coeffprod = coeff * plusterm ;
302 complex<double> coeffmix = pow(
m_qoverp, tag) * coeff * minusterm ;
303 return AmpPair(coeffprod, coeffmix) ;
307 const std::string& name) {
308 TH1F histo(name.c_str(),
"", nbins, tmin, tmax) ;
310 for(
unsigned i = 1 ; i < nbins + 1 ; ++i){
311 double time = histo.GetXaxis()->GetBinCenter(i) ;
313 histo.SetBinContent(i, val) ;
314 histo.SetBinError(i, 0.) ;
320 const std::string& name) {
321 TH1F histo(name.c_str(),
"", nbins, tmin, tmax) ;
322 for(
unsigned i = 1 ; i < nbins + 1 ; ++i){
323 double time = histo.GetXaxis()->GetBinCenter(i) ;
325 histo.SetBinContent(i, val) ;
326 histo.SetBinError(i, 0.) ;
FitAmpIncoherentSum m_bothmodel
virtual const std::vector< double > & getVectorOfValues() const
void setDecayTime(double)
virtual MINT::counted_ptr< IDalitzEvent > newEvent()
double envelope_value(const double, IDalitzEvent &)
virtual double Prob(IDalitzEvent &evt)
void setEfficiency(const MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > &eff)
double pdf_value(int, double, IDalitzEvent &)
virtual std::complex< double > ComplexVal(IDalitzEvent &evt)
virtual std::complex< double > getVal(IDalitzEvent &evt)
Eff3piSymmetric * m_sEfficiency
static std::map< std::string, unsigned > infoNames
std::pair< double, double > generate_decay_time() const
Generate a decay time, optionally including experimental effects.
virtual int addAsList(const FitAmpListBase &other, double factor=1)
float get_gen_efficiency() const
void setSmearedDecayTime(double)
double getDecayTime() const
static DalitzEventPattern anti(DalitzEventPattern pat)
Take the CP conjugate of the head of the decay pattern.
double getVal(IDalitzEvent &evt)
TimeDependentGenerator(const DalitzEventPattern &pattern, double width, double deltam, double deltagamma, double qoverp, double phi, TRandom3 *rndm, TH1F *h_efficiency=NULL, float resWidth=0.05, bool addExpEffects=false, Eff3piSymmetric *sEfficiency=NULL)
bool accept_or_reject(const int tag, const double decaytime, IDalitzEvent &)
Decide whether the generated event should be accepted or rejected.
double getSmearedDecayTime() const
virtual double getValueFromVector(unsigned int i) const =0
static std::map< std::string, unsigned > makeInfoNames()
MINT::counted_ptr< FitAmpSum > m_cpmodel
TH1F draw_envelope_vs_time(IDalitzEvent &, unsigned, float, float, const std::string &name="envelope_vs_time")
SignalGenerator m_generator
const double m_deltagamma
TH1F draw_pdf_vs_time(IDalitzEvent &, unsigned, float, float, const std::string &name="pdf_vs_time")
MINT::counted_ptr< IDalitzEvent > generate_event()
Generate a flavour, decay time and Dalitz event.
AmpPair amplitude_coefficients(const int tag, const double decaytime)
const std::complex< double > m_qoverp
const DalitzEventPattern m_pattern
GenTimeEvent(const IDalitzEvent &, const int, const double, const double smeareddecaytime=-999.)
MINT::counted_ptr< FitAmpSum > m_model
std::pair< std::complex< double >, std::complex< double > > AmpPair
const DalitzEventPattern m_cppattern