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.
EvtAbsLineShape.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/EvtComplex.hh"
24 #include "EvtGenBase/EvtPDL.hh"
25 #include "EvtGenBase/EvtPatches.hh"
27 #include "EvtGenBase/EvtRandom.hh"
28 #include "EvtGenBase/EvtReport.hh"
30 
31 #include <ctype.h>
32 #include <iostream>
33 #include <math.h>
34 #include <stdlib.h>
35 
36 using namespace std;
37 
38 EvtAbsLineShape::EvtAbsLineShape( double mass, double width, double maxRange,
40 {
41  _includeDecayFact = false;
42  _includeBirthFact = false;
43  _mass = mass;
44  _width = width;
45  _spin = sp;
46  _maxRange = maxRange;
47  double maxdelta = 15.0 * width;
48  //if ( width>0.001 ) {
49  // if ( 5.0*width < 0.6 ) maxdelta = 0.6;
50  //}
51  if ( maxRange > 0.00001 ) {
52  _massMax = mass + maxdelta;
53  _massMin = mass - maxRange;
54  } else {
55  _massMax = mass + maxdelta;
56  _massMin = mass - 15.0 * width;
57  }
58  if ( _massMin < 0. )
59  _massMin = 0.;
60  _massMax = mass + maxdelta;
61 }
62 
64 {
65  _includeDecayFact = x._includeDecayFact;
66  _includeBirthFact = x._includeBirthFact;
67  _mass = x._mass;
68  _massMax = x._massMax;
69  _massMin = x._massMin;
70  _width = x._width;
71  _spin = x._spin;
72  _maxRange = x._maxRange;
73 }
74 
76 {
77  _includeDecayFact = x._includeDecayFact;
78  _includeBirthFact = x._includeBirthFact;
79  _mass = x._mass;
80  _massMax = x._massMax;
81  _massMin = x._massMin;
82  _width = x._width;
83  _spin = x._spin;
84  _maxRange = x._maxRange;
85  return *this;
86 }
87 
89 {
90  return new EvtAbsLineShape( *this );
91 }
92 
94 {
95  double ymin, ymax;
96  double temp;
97 
98  if ( _width < 0.0001 ) {
99  return _mass;
100  } else {
101  ymin = atan( 2.0 * ( _massMin - _mass ) / _width );
102  ymax = atan( 2.0 * ( _massMax - _mass ) / _width );
103 
104  temp = ( _mass +
105  ( ( _width / 2.0 ) * tan( EvtRandom::Flat( ymin, ymax ) ) ) );
106 
107  return temp;
108  }
109 }
110 double EvtAbsLineShape::getRandMass( EvtId* parId, int /* nDaug */,
111  EvtId* /*dauId*/, EvtId* /*othDaugId*/,
112  double maxMass, double* /*dauMasses*/ )
113 {
114  if ( _width < 0.0001 )
115  return _mass;
116  //its not flat - but generated according to a BW
117 
118  if ( maxMass > 0 && maxMass < _massMin ) {
119  EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
120  << "In EvtAbsLineShape::getRandMass:" << endl;
121  EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
122  << "Cannot create a particle with a minimal mass of " << _massMin
123  << " from a " << EvtPDL::name( *parId )
124  << " decay with available left-over mass-energy " << maxMass
125  << ". Returning 0.0 mass. The rest of this decay chain will probably fail..."
126  << endl;
127  return 0.0;
128  }
129 
130  double mMin = _massMin;
131  double mMax = _massMax;
132  if ( maxMass > -0.5 && maxMass < mMax )
133  mMax = maxMass;
134  double ymin = atan( 2.0 * ( mMin - _mass ) / _width );
135  double ymax = atan( 2.0 * ( mMax - _mass ) / _width );
136 
137  return ( _mass + ( ( _width / 2.0 ) * tan( EvtRandom::Flat( ymin, ymax ) ) ) );
138  // return EvtRandom::Flat(_massMin,_massMax);
139 }
140 
141 double EvtAbsLineShape::getMassProb( double mass, double massPar, int nDaug,
142  double* massDau )
143 {
144  double dTotMass = 0.;
145  if ( nDaug > 1 ) {
146  int i;
147  for ( i = 0; i < nDaug; i++ ) {
148  dTotMass += massDau[i];
149  }
150  //EvtGenReport(EVTGEN_INFO,"EvtGen") << mass << " " << massPar << " " << dTotMass << " "<< endl;
151  // if ( (mass-dTotMass)<0.0001 ) return 0.;
152  if ( ( mass < dTotMass ) )
153  return 0.;
154  }
155  if ( _width < 0.0001 )
156  return 1.;
157 
158  // no parent - lets not panic
159  if ( massPar > 0.0000000001 ) {
160  if ( mass > massPar )
161  return 0.;
162  }
163  //Otherwise return the right value.
164  //Fortunately we have generated events according to a non-rel BW, so
165  //just return..
166  //EvtPropBreitWigner bw(_mass,_width);
167  //EvtPropFactor<EvtTwoBodyVertex> f(bw);
168  //EvtComplex fm=f.eval(mass);
169  //EvtComplex fm0=f.eval(_mass);
170  //return (abs(fm)*abs(fm))/(abs(fm0)*abs(fm0));
171  return 1.0;
172 }
virtual EvtAbsLineShape * clone()
static std::string name(EvtId i)
Definition: EvtPDL.cpp:382
virtual double getMassProb(double mass, double massPar, int nDaug, double *massDau)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
virtual double rollMass()
Definition: EvtId.hh:27
EvtAbsLineShape()=default
static double Flat()
Definition: EvtRandom.cpp:72
virtual double getRandMass(EvtId *parId, int nDaug, EvtId *dauId, EvtId *othDaugId, double maxMass, double *dauMasses)
EvtSpinType::spintype _spin
EvtAbsLineShape & operator=(const EvtAbsLineShape &x)