1 //-----------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: EvtIntervalDecayAmp.hh,v 1.4 2009-03-16 16:39:16 robbep Exp $
6 // This software is part of the EvtGen package developed jointly
7 // for the BaBar and CLEO collaborations. If you use all or part
8 // of it, please give an appropriate acknowledgement.
10 // Copyright Information:
11 // Copyright (C) 1998 Caltech, UCSB
14 // Alexei Dvoretskii, Caltech, 2001-2002.
15 //-----------------------------------------------------------------------
17 // Decay model that uses the "amplitude on an interval"
20 #ifndef EVT_INTERVAL_DECAY_AMP
21 #define EVT_INTERVAL_DECAY_AMP
27 #include "EvtGenBase/EvtDecayAmp.hh"
28 #include "EvtGenBase/EvtParticle.hh"
29 #include "EvtGenBase/EvtMacros.hh"
30 #include "EvtGenBase/EvtPdf.hh"
31 #include "EvtGenBase/EvtAmpFactory.hh"
32 #include "EvtGenBase/EvtMultiChannelParser.hh"
33 #include "EvtGenBase/EvtAmpPdf.hh"
34 #include "EvtGenBase/EvtCPUtil.hh"
35 #include "EvtGenBase/EvtPDL.hh"
36 #include "EvtGenBase/EvtCyclic3.hh"
37 #include "EvtGenBase/EvtReport.hh"
40 class EvtIntervalDecayAmp : public EvtDecayAmp {
45 : _probMax(0.), _nScan(0), _fact(0)
48 EvtIntervalDecayAmp(const EvtIntervalDecayAmp<T>& other)
49 : _probMax(other._probMax), _nScan(other._nScan),
53 virtual ~EvtIntervalDecayAmp()
63 // Collect model parameters and parse them
65 vector<std::string> args;
67 for(i=0;i<getNArg();i++) args.push_back(getArgStr(i));
68 EvtMultiChannelParser parser;
71 // Create factory and interval
73 if(VERBOSE) report(INFO,"EvtGen") << "Create factory and interval" << std::endl;
74 _fact = createFactory(parser);
76 // Maximum PDF value over the Dalitz plot can be specified, or a scan
79 _probMax = parser.pdfMax();
80 _nScan = parser.nScan();
81 if(VERBOSE) report(INFO,"EvtGen") << "Pdf maximum " << _probMax << std::endl;
82 if(VERBOSE) report(INFO,"EvtGen") << "Scan number " << _nScan << std::endl;
86 virtual void initProbMax()
90 if(_probMax > 0) setProbMax(_probMax);
95 double factor = 1.2; // increase maximum probability by 20%
96 EvtAmpPdf<T> pdf(*_fact->getAmp());
97 EvtPdfSum<T>* pc = _fact->getPC();
98 EvtPdfDiv<T> pdfdiv(pdf,*pc);
99 printf("Sampling %d points to find maximum\n",_nScan);
100 EvtPdfMax<T> x = pdfdiv.findMax(*pc,_nScan);
101 _probMax = factor * x.value();
102 printf("Found maximum %f\n",x.value());
103 printf("Increase to %f\n",_probMax);
104 setProbMax(_probMax);
108 virtual void decay(EvtParticle *p)
110 // Set things up in most general way
112 static EvtId B0=EvtPDL::getId("B0");
113 static EvtId B0B=EvtPDL::getId("anti-B0");
116 EvtComplex ampl(0.,0.);
118 // Sample using pole-compensator pdf
120 EvtPdfSum<T>* pc = getPC();
121 _x = pc->randomPoint();
123 if(_fact->isCPModel()) {
125 // Time-dependent Dalitz plot changes
126 // Dec 2005 (ddujmic@slac.stanford.edu)
128 EvtComplex A = _fact->getAmp()->evaluate(_x);
129 EvtComplex Abar = _fact->getAmpConj()->evaluate(_x);
131 EvtCPUtil::getInstance()->OtherB(p,t,other_b);
133 double dm = _fact->dm();
134 double mixAmpli = _fact->mixAmpli();
135 double mixPhase = _fact->mixPhase();
136 EvtComplex qoverp( cos(mixPhase)*mixAmpli, sin(mixPhase)*mixAmpli);
137 EvtComplex poverq( cos(mixPhase)/mixAmpli, -sin(mixPhase)/mixAmpli);
140 if (other_b==B0B) ampl = A*cos(dm*t/(2*EvtConst::c)) +
141 EvtComplex(0.,1.)*Abar*sin(dm*t/(2*EvtConst::c))*qoverp;
142 if (other_b==B0) ampl = Abar*cos(dm*t/(2*EvtConst::c)) +
143 EvtComplex(0.,1.)*A*sin(dm*t/(2*EvtConst::c))*poverq;
149 ampl = amplNonCP(_x);
154 double comp = sqrt(pc->evaluate(_x));
158 // Now generate random angles, rotate and setup
161 std::vector<EvtVector4R> v = initDaughters(_x);
163 size_t N = p->getNDaug();
166 report(INFO,"EvtGen") << "Number of daughters " << N << std::endl;
167 report(INFO,"EvtGen") << "Momentum vector size " << v.size() << std::endl;
171 for(size_t i=0;i<N;i++){
173 p->getDaug(i)->init(getDaugs()[i],v[i]);
177 virtual EvtAmpFactory<T>* createFactory(const EvtMultiChannelParser& parser) = 0;
178 virtual std::vector<EvtVector4R> initDaughters(const T& p) const = 0;
180 // provide access to the decay point and to the amplitude of any decay point.
181 // this is used by EvtBtoKD3P:
182 const T & x() const {return _x;}
183 EvtComplex amplNonCP(const T & x) {return _fact->getAmp()->evaluate(x);}
184 EvtPdfSum<T>* getPC() {return _fact->getPC();}
187 double _probMax; // Maximum probability
188 int _nScan; // Number of points for max prob DP scan
191 EvtAmpFactory<T>* _fact; // factory