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.
EvtThreeBodyPhsp.cpp
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 
22 
23 #include "EvtGenBase/EvtConst.hh"
24 #include "EvtGenBase/EvtGenKine.hh"
26 #include "EvtGenBase/EvtRandom.hh"
27 #include "EvtGenBase/EvtReport.hh"
28 
29 #include <algorithm>
30 #include <cmath>
31 #include <iostream>
32 
34 {
35  return "THREEBODYPHSP";
36 }
37 
39 {
40  return new EvtThreeBodyPhsp;
41 }
42 
44 {
45  // check correct number of arguments
46  checkNArg( 2, 4 );
47  // check number of daughters
48  checkNDaug( 3 );
49  // Get box size
50  m_m12SqMin = getArg( 0 );
51  m_m12SqMax = getArg( 1 );
52  if ( getNArg() > 2 ) {
53  m_m23SqMin = getArg( 2 );
54  m_m23SqMax = getArg( 3 );
55  } else {
56  m_m23SqMin = 0;
57  m_m23SqMax = 1e10;
58  }
59 }
60 
62 {
63  noProbMax();
64 }
65 
67 {
68  p->makeDaughters( getNDaug(), getDaugs() );
69  p->generateMassTree();
70  const double mParent = p->mass();
71  EvtParticle* daug1 = p->getDaug( 0 );
72  EvtParticle* daug2 = p->getDaug( 1 );
73  EvtParticle* daug3 = p->getDaug( 2 );
74  const double mDaug1 = daug1->mass();
75  const double mDaug2 = daug2->mass();
76  const double mDaug3 = daug3->mass();
77 
78  const double m12borderMin = mDaug1 + mDaug2;
79  const double m12borderMax = mParent - mDaug3;
80  const double m12Min = std::max( m_m12SqMin, m12borderMin * m12borderMin );
81  const double m12Max = std::min( m_m12SqMax, m12borderMax * m12borderMax );
82 
83  const double m23borderMin = mDaug2 + mDaug3;
84  const double m23borderMax = mParent - mDaug1;
85  const double m23Min = std::max( m_m23SqMin, m23borderMin * m23borderMin );
86  const double m23Max = std::min( m_m23SqMax, m23borderMax * m23borderMax );
87 
88  const int nMaxTrials = 1000;
89  int iTrial = 0;
90  bool goodEvent = false;
91  double m12Sq, m23Sq, m23LowLimit, m23HighLimit;
92  do {
93  m12Sq = EvtRandom::Flat( m12Min, m12Max );
94  m23Sq = EvtRandom::Flat( m23Min, m23Max );
95  // By definition, m12Sq is always within Dalitz plot, but need to check
96  // that also m23Sq is in
97  double E2st = 0.5 * ( m12Sq - mDaug1 * mDaug1 + mDaug2 * mDaug2 ) /
98  std::sqrt( m12Sq );
99  double E3st = 0.5 * ( mParent * mParent - m12Sq - mDaug3 * mDaug3 ) /
100  std::sqrt( m12Sq );
101  double p2st = std::sqrt( E2st * E2st - mDaug2 * mDaug2 );
102  double p3st = std::sqrt( E3st * E3st - mDaug3 * mDaug3 );
103  m23HighLimit = ( E2st + E3st ) * ( E2st + E3st ) -
104  ( p2st - p3st ) * ( p2st - p3st );
105  m23LowLimit = ( E2st + E3st ) * ( E2st + E3st ) -
106  ( p2st + p3st ) * ( p2st + p3st );
107  if ( m23Sq > m23LowLimit && m23Sq < m23HighLimit ) {
108  goodEvent = true;
109  }
110  ++iTrial;
111  } while ( goodEvent == false && iTrial < nMaxTrials );
112  if ( !goodEvent ) {
113  EvtGenReport( EVTGEN_WARNING, "EvtThreeBodyPhsp" )
114  << "Failed to generate m12Sq and m23Sq. Taking last m12Sq and midpoint of allowed m23Sq.\n";
115  m23Sq = 0.5 * ( m23LowLimit + m23HighLimit );
116  }
117 
118  // At this moment we have valid invariant masses squared
119  EvtGenKine::ThreeBodyKine( m12Sq, m23Sq, p );
120 
121  return;
122 }
double getArg(unsigned int j)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
void decay(EvtParticle *p) override
std::string getName() override
void makeDaughters(unsigned int ndaug, EvtId *id)
EvtId * getDaugs()
Definition: EvtDecayBase.hh:66
bool generateMassTree()
void checkNDaug(int d1, int d2=-1)
static double Flat()
Definition: EvtRandom.cpp:72
static void ThreeBodyKine(const double m12Sq, const double m23Sq, EvtParticle *p)
Definition: EvtGenKine.cpp:350
void checkNArg(int a1, int a2=-1, int a3=-1, int a4=-1)
void init() override
double mass() const
int getNDaug() const
Definition: EvtDecayBase.hh:65
EvtDecayBase * clone() override
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
void initProbMax() override
int getNArg() const
Definition: EvtDecayBase.hh:68