StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EvtIntervalDecayAmp.hh
1 //-----------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: EvtIntervalDecayAmp.hh,v 1.1 2016/09/23 18:37:37 jwebb Exp $
4 //
5 // Environment:
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.
9 //
10 // Copyright Information:
11 // Copyright (C) 1998 Caltech, UCSB
12 //
13 // Module creator:
14 // Alexei Dvoretskii, Caltech, 2001-2002.
15 //-----------------------------------------------------------------------
16 
17 // Decay model that uses the "amplitude on an interval"
18 // templatization
19 
20 #ifndef EVT_INTERVAL_DECAY_AMP
21 #define EVT_INTERVAL_DECAY_AMP
22 
23 #include <iostream>
24 #include <vector>
25 #include <string>
26 #include "EvtGenBase/EvtDecayAmp.hh"
27 #include "EvtGenBase/EvtParticle.hh"
28 #include "EvtGenBase/EvtMacros.hh"
29 #include "EvtGenBase/EvtPdf.hh"
30 #include "EvtGenBase/EvtAmpFactory.hh"
31 #include "EvtGenBase/EvtMultiChannelParser.hh"
32 #include "EvtGenBase/EvtAmpPdf.hh"
33 #include "EvtGenBase/EvtCPUtil.hh"
34 #include "EvtGenBase/EvtPDL.hh"
35 #include "EvtGenBase/EvtCyclic3.hh"
36 #include "EvtGenBase/EvtReport.hh"
37 
38 template <class T>
40 
41 public:
42 
44  : _probMax(0.), _nScan(0), _fact(0)
45  {}
46 
48  : _probMax(other._probMax), _nScan(other._nScan),
49  COPY_PTR(_fact)
50  {}
51 
52  virtual ~EvtIntervalDecayAmp()
53  {
54  delete _fact;
55  }
56 
57 
58  // Initialize model
59 
60  virtual void init()
61  {
62  // Collect model parameters and parse them
63 
64  vector<std::string> args;
65  int i;
66  for(i=0;i<getNArg();i++) args.push_back(getArgStr(i));
67  EvtMultiChannelParser parser;
68  parser.parse(args);
69 
70  // Create factory and interval
71 
72  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Create factory and interval" << std::endl;
73  _fact = createFactory(parser);
74 
75  // Maximum PDF value over the Dalitz plot can be specified, or a scan
76  // can be performed.
77 
78  _probMax = parser.pdfMax();
79  _nScan = parser.nScan();
80  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Pdf maximum " << _probMax << std::endl;
81  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Scan number " << _nScan << std::endl;
82  }
83 
84 
85  virtual void initProbMax()
86  {
87  if(0 == _nScan) {
88 
89  if(_probMax > 0) setProbMax(_probMax);
90  else assert(0);
91  }
92  else {
93 
94  double factor = 1.2; // increase maximum probability by 20%
95  EvtAmpPdf<T> pdf(*_fact->getAmp());
96  EvtPdfSum<T>* pc = _fact->getPC();
97  EvtPdfDiv<T> pdfdiv(pdf,*pc);
98  printf("Sampling %d points to find maximum\n",_nScan);
99  EvtPdfMax<T> x = pdfdiv.findMax(*pc,_nScan);
100  _probMax = factor * x.value();
101  printf("Found maximum %f\n",x.value());
102  printf("Increase to %f\n",_probMax);
103  setProbMax(_probMax);
104  }
105  }
106 
107  virtual void decay(EvtParticle *p)
108  {
109  // Set things up in most general way
110 
111  static EvtId B0=EvtPDL::getId("B0");
112  static EvtId B0B=EvtPDL::getId("anti-B0");
113  double t;
114  EvtId other_b;
115  EvtComplex ampl(0.,0.);
116 
117  // Sample using pole-compensator pdf
118 
119  EvtPdfSum<T>* pc = getPC();
120  _x = pc->randomPoint();
121 
122  if(_fact->isCPModel()) {
123 
124  // Time-dependent Dalitz plot changes
125  // Dec 2005 (ddujmic@slac.stanford.edu)
126 
127  EvtComplex A = _fact->getAmp()->evaluate(_x);
128  EvtComplex Abar = _fact->getAmpConj()->evaluate(_x);
129 
130  EvtCPUtil::getInstance()->OtherB(p,t,other_b);
131 
132  double dm = _fact->dm();
133  double mixAmpli = _fact->mixAmpli();
134  double mixPhase = _fact->mixPhase();
135  EvtComplex qoverp( cos(mixPhase)*mixAmpli, sin(mixPhase)*mixAmpli);
136  EvtComplex poverq( cos(mixPhase)/mixAmpli, -sin(mixPhase)/mixAmpli);
137 
138 
139  if (other_b==B0B) ampl = A*cos(dm*t/(2*EvtConst::c)) +
140  EvtComplex(0.,1.)*Abar*sin(dm*t/(2*EvtConst::c))*qoverp;
141  if (other_b==B0) ampl = Abar*cos(dm*t/(2*EvtConst::c)) +
142  EvtComplex(0.,1.)*A*sin(dm*t/(2*EvtConst::c))*poverq;
143 
144 
145  }
146  else {
147 
148  ampl = amplNonCP(_x);
149  }
150 
151  // Pole-compensate
152 
153  double comp = sqrt(pc->evaluate(_x));
154  assert(comp > 0);
155  vertex(ampl/comp);
156 
157  // Now generate random angles, rotate and setup
158  // the daughters
159 
160  std::vector<EvtVector4R> v = initDaughters(_x);
161 
162  size_t N = p->getNDaug();
163  if(v.size() != N) {
164 
165  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Number of daughters " << N << std::endl;
166  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Momentum vector size " << v.size() << std::endl;
167  assert(0);
168  }
169 
170  for(size_t i=0;i<N;i++){
171 
172  p->getDaug(i)->init(getDaugs()[i],v[i]);
173  }
174  }
175 
176  virtual EvtAmpFactory<T>* createFactory(const EvtMultiChannelParser& parser) = 0;
177  virtual std::vector<EvtVector4R> initDaughters(const T& p) const = 0;
178 
179  // provide access to the decay point and to the amplitude of any decay point.
180  // this is used by EvtBtoKD3P:
181  const T & x() const {return _x;}
182  EvtComplex amplNonCP(const T & x) {return _fact->getAmp()->evaluate(x);}
183  EvtPdfSum<T>* getPC() {return _fact->getPC();}
184 
185 protected:
186  double _probMax; // Maximum probability
187  int _nScan; // Number of points for max prob DP scan
188  T _x; // Decay point
189 
190  EvtAmpFactory<T>* _fact; // factory
191 };
192 
193 
194 #endif
195 
196 
197 
198 
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
EvtParticle * getDaug(int i)
size_t getNDaug() const
Definition: EvtId.hh:27
void vertex(const EvtComplex &amp)
Definition: EvtDecayAmp.hh:37