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.
EvtFlatQ2.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/EvtPDL.hh"
25 #include "EvtGenBase/EvtPatches.hh"
26 #include "EvtGenBase/EvtReport.hh"
27 
28 #include <fstream>
29 #include <string>
30 
31 double lambda( double q, double m1, double m2 )
32 {
33  double L( 1.0 );
34  double mSum = m1 + m2;
35  double mDiff = m1 - m2;
36  double qSq = q * q;
37 
38  if ( qSq > 0.0 ) {
39  double prodTerm = ( qSq - mSum * mSum ) * ( qSq - mDiff * mDiff );
40 
41  if ( prodTerm > 0.0 ) {
42  L = sqrt( prodTerm ) / qSq;
43  }
44  }
45 
46  return L;
47 }
48 
49 std::string EvtFlatQ2::getName()
50 {
51  return "FLATQ2";
52 }
53 
55 {
56  return new EvtFlatQ2;
57 }
58 
60 {
61  setProbMax( 100 );
62 }
63 
65 {
66  // check that there are 3 daughters
67  checkNDaug( 3 );
68 
69  // We expect B -> X lepton lepton events
71 
74 
75  if ( !( d1type == EvtSpinType::DIRAC || d1type == EvtSpinType::NEUTRINO ) ) {
76  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
77  << "EvtFlatQ2 expects 2nd daughter to "
78  << "be a lepton" << std::endl;
79  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
80  << "Will terminate execution!" << std::endl;
81  ::abort();
82  }
83 
84  if ( !( d2type == EvtSpinType::DIRAC || d2type == EvtSpinType::NEUTRINO ) ) {
85  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
86  << "EvtFlatQ2 expects 3rd daughter to "
87  << "be a lepton" << std::endl;
88  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
89  << "Will terminate execution!" << std::endl;
90  ::abort();
91  }
92 
93  // Specify if we want to use the phase space factor
94  _usePhsp = false;
95  if ( getNArg() > 0 ) {
96  if ( getArg( 0 ) != 0 ) {
97  _usePhsp = true;
98  }
99  }
100 
101  EvtGenReport( EVTGEN_INFO, "EvtGen" )
102  << "EvtFlatQ2 usePhsp = " << int( _usePhsp ) << std::endl;
103 }
104 
106 {
108 
109  EvtVector4R p4Xu = p->getDaug( 0 )->getP4();
110 
111  EvtVector4R p4ell1 = p->getDaug( 1 )->getP4();
112  EvtVector4R p4ell2 = p->getDaug( 2 )->getP4();
113 
114  double pXu_x2 = p4Xu.get( 1 ) * p4Xu.get( 1 );
115  double pXu_y2 = p4Xu.get( 2 ) * p4Xu.get( 2 );
116  double pXu_z2 = p4Xu.get( 3 ) * p4Xu.get( 3 );
117  double pXu = sqrt( pXu_x2 + pXu_y2 + pXu_z2 );
118  double prob( 0.0 );
119  if ( fabs( pXu ) > 0.0 ) {
120  prob = 1 / pXu;
121  }
122 
123  // Include the phase space factor if requested
124  if ( _usePhsp ) {
125  // Invariant mass of lepton pair
126  double q = ( p4ell1 + p4ell2 ).mass();
127  // Rest masses of the leptons
128  double m1 = p4ell1.mass();
129  double m2 = p4ell2.mass();
130  // Phase space factor, which includes the various square roots
131  double Lambda = lambda( q, m1, m2 );
132  if ( Lambda > 0.0 ) {
133  prob = prob / Lambda;
134  }
135  }
136 
137  if ( pXu > 0.01 ) {
138  setProb( prob );
139  }
140 
141  return;
142 }
void setProb(double prob)
Definition: EvtDecayProb.hh:32
double getArg(unsigned int j)
static EvtSpinType::spintype getSpinType(EvtId i)
Definition: EvtPDL.cpp:377
bool _usePhsp
Definition: EvtFlatQ2.hh:41
EvtDecayBase * clone() override
Definition: EvtFlatQ2.cpp:54
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
double mass() const
Definition: EvtVector4R.cpp:49
void initProbMax() override
Definition: EvtFlatQ2.cpp:59
EvtId * getDaugs()
Definition: EvtDecayBase.hh:66
std::string getName() override
Definition: EvtFlatQ2.cpp:49
void setProbMax(double prbmx)
double get(int i) const
Definition: EvtVector4R.hh:162
double initializePhaseSpace(unsigned int numdaughter, EvtId *daughters, bool forceResetMasses=false, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
void checkNDaug(int d1, int d2=-1)
void checkSpinParent(EvtSpinType::spintype sp)
const EvtVector4R & getP4() const
double lambda(double q, double m1, double m2)
Definition: EvtFlatQ2.cpp:31
void init() override
Definition: EvtFlatQ2.cpp:64
int getNDaug() const
Definition: EvtDecayBase.hh:65
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
int getNArg() const
Definition: EvtDecayBase.hh:68
void decay(EvtParticle *p) override
Definition: EvtFlatQ2.cpp:105
EvtId getDaug(int i) const
Definition: EvtDecayBase.hh:67