evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtIntervalDecayAmp.hh
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
21 #ifndef EVT_INTERVAL_DECAY_AMP
22 #define EVT_INTERVAL_DECAY_AMP
23 
24 #define VERBOSE true
26 #include "EvtGenBase/EvtAmpPdf.hh"
27 #include "EvtGenBase/EvtCPUtil.hh"
28 #include "EvtGenBase/EvtCyclic3.hh"
30 #include "EvtGenBase/EvtMacros.hh"
32 #include "EvtGenBase/EvtPDL.hh"
34 #include "EvtGenBase/EvtPdf.hh"
35 #include "EvtGenBase/EvtReport.hh"
36 
37 #include <iostream>
38 #include <string>
39 #include <vector>
40 
41 // Decay model that uses the "amplitude on an interval"
42 // templatization
43 
44 template <class T>
46  public:
47  EvtIntervalDecayAmp() : _probMax( 0. ), _nScan( 0 ), _fact( 0 ) {}
48 
51  {
52  }
53 
54  virtual ~EvtIntervalDecayAmp() { delete _fact; }
55 
56  // Initialize model
57 
58  void init() override
59  {
60  // Collect model parameters and parse them
61 
62  vector<std::string> args;
63  int i;
64  for ( i = 0; i < getNArg(); i++ )
65  args.push_back( getArgStr( i ) );
66  EvtMultiChannelParser parser;
67  parser.parse( args );
68 
69  // Create factory and interval
70 
71  if ( VERBOSE )
72  EvtGenReport( EVTGEN_INFO, "EvtGen" )
73  << "Create factory and interval" << std::endl;
74  _fact = createFactory( parser );
75 
76  // Maximum PDF value over the Dalitz plot can be specified, or a scan
77  // can be performed.
78 
79  _probMax = parser.pdfMax();
80  _nScan = parser.nScan();
81  if ( VERBOSE )
82  EvtGenReport( EVTGEN_INFO, "EvtGen" )
83  << "Pdf maximum " << _probMax << std::endl;
84  if ( VERBOSE )
85  EvtGenReport( EVTGEN_INFO, "EvtGen" )
86  << "Scan number " << _nScan << std::endl;
87  }
88 
89  void initProbMax() override
90  {
91  if ( 0 == _nScan ) {
92  if ( _probMax > 0 )
94  else
95  assert( 0 );
96  } else {
97  double factor = 1.2; // increase maximum probability by 20%
98  EvtAmpPdf<T> pdf( *_fact->getAmp() );
99  EvtPdfSum<T>* pc = _fact->getPC();
100  EvtPdfDiv<T> pdfdiv( pdf, *pc );
101  printf( "Sampling %d points to find maximum\n", _nScan );
102  EvtPdfMax<T> x = pdfdiv.findMax( *pc, _nScan );
103  _probMax = factor * x.value();
104  printf( "Found maximum %f\n", x.value() );
105  printf( "Increase to %f\n", _probMax );
106  setProbMax( _probMax );
107  }
108  }
109 
110  void decay( EvtParticle* p ) override
111  {
112  // Set things up in most general way
113 
114  static EvtId B0 = EvtPDL::getId( "B0" );
115  static EvtId B0B = EvtPDL::getId( "anti-B0" );
116  double t;
117  EvtId other_b;
118  EvtComplex ampl( 0., 0. );
119 
120  // Sample using pole-compensator pdf
121 
122  EvtPdfSum<T>* pc = getPC();
123  _x = pc->randomPoint();
124 
125  if ( _fact->isCPModel() ) {
126  // Time-dependent Dalitz plot changes
127  // Dec 2005 (ddujmic@slac.stanford.edu)
128 
129  EvtComplex A = _fact->getAmp()->evaluate( _x );
130  EvtComplex Abar = _fact->getAmpConj()->evaluate( _x );
131 
132  EvtCPUtil::getInstance()->OtherB( p, t, other_b );
133 
134  double dm = _fact->dm();
135  double mixAmpli = _fact->mixAmpli();
136  double mixPhase = _fact->mixPhase();
137  EvtComplex qoverp( cos( mixPhase ) * mixAmpli,
138  sin( mixPhase ) * mixAmpli );
139  EvtComplex poverq( cos( mixPhase ) / mixAmpli,
140  -sin( mixPhase ) / mixAmpli );
141 
142  if ( other_b == B0B )
143  ampl = A * cos( dm * t / ( 2 * EvtConst::c ) ) +
144  EvtComplex( 0., 1. ) * Abar *
145  sin( dm * t / ( 2 * EvtConst::c ) ) * qoverp;
146  if ( other_b == B0 )
147  ampl = Abar * cos( dm * t / ( 2 * EvtConst::c ) ) +
148  EvtComplex( 0., 1. ) * A *
149  sin( dm * t / ( 2 * EvtConst::c ) ) * poverq;
150 
151  } else {
152  ampl = amplNonCP( _x );
153  }
154 
155  // Pole-compensate
156 
157  double comp = sqrt( pc->evaluate( _x ) );
158  assert( comp > 0 );
159  vertex( ampl / comp );
160 
161  // Now generate random angles, rotate and setup
162  // the daughters
163 
164  std::vector<EvtVector4R> v = initDaughters( _x );
165 
166  size_t N = p->getNDaug();
167  if ( v.size() != N ) {
168  EvtGenReport( EVTGEN_INFO, "EvtGen" )
169  << "Number of daughters " << N << std::endl;
170  EvtGenReport( EVTGEN_INFO, "EvtGen" )
171  << "Momentum vector size " << v.size() << std::endl;
172  assert( 0 );
173  }
174 
175  for ( size_t i = 0; i < N; i++ ) {
176  p->getDaug( i )->init( getDaugs()[i], v[i] );
177  }
178  }
179 
181  const EvtMultiChannelParser& parser ) = 0;
182  virtual std::vector<EvtVector4R> initDaughters( const T& p ) const = 0;
183 
184  // provide access to the decay point and to the amplitude of any decay point.
185  // this is used by EvtBtoKD3P:
186  const T& x() const { return _x; }
187  EvtComplex amplNonCP( const T& x )
188  {
189  return _fact->getAmp()->evaluate( x );
190  }
191  EvtPdfSum<T>* getPC() { return _fact->getPC(); }
192 
193  protected:
194  double _probMax; // Maximum probability
195  int _nScan; // Number of points for max prob DP scan
196  T _x; // Decay point
197 
198  EvtAmpFactory<T>* _fact; // factory
199 };
200 
201 #endif
virtual std::vector< EvtVector4R > initDaughters(const T &p) const =0
double evaluate(const T &p) const
Definition: EvtPdf.hh:79
EvtIntervalDecayAmp(const EvtIntervalDecayAmp< T > &other)
void parse(const char *file, const char *model)
std::string getArgStr(int j) const
Definition: EvtDecayBase.hh:78
EvtPdfSum< T > * getPC()
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
virtual EvtAmpFactory< T > * createFactory(const EvtMultiChannelParser &parser)=0
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void decay(EvtParticle *p) override
void OtherB(EvtParticle *p, double &t, EvtId &otherb)
Definition: EvtCPUtil.cpp:372
T randomPoint() override
Definition: EvtPdfSum.hh:129
EvtId * getDaugs()
Definition: EvtDecayBase.hh:66
void setProbMax(double prbmx)
Definition: EvtId.hh:27
size_t getNDaug() const
EvtAmpFactory< T > * _fact
void vertex(const EvtComplex &amp)
Definition: EvtDecayAmp.hh:37
#define VERBOSE
static const double c
Definition: EvtConst.hh:30
static EvtId getId(const std::string &name)
Definition: EvtPDL.cpp:287
void initProbMax() override
#define COPY_PTR(X)
Definition: EvtMacros.hh:26
static EvtCPUtil * getInstance()
Definition: EvtCPUtil.cpp:43
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
EvtComplex amplNonCP(const T &x)
int getNArg() const
Definition: EvtDecayBase.hh:68
Index other(Index i, Index j)
Definition: EvtCyclic3.cpp:156
EvtPdfMax< T > findMax(const EvtPdf< T > &pc, int N)
Definition: EvtPdf.hh:260