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.
EvtPhotonParticle.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/EvtPatches.hh"
25 #include "EvtGenBase/EvtReport.hh"
27 
28 #include <iostream>
29 #include <math.h>
30 #include <stdlib.h>
31 using std::endl;
32 
33 void EvtPhotonParticle::init( EvtId part_n, const EvtVector4R& p4 )
34 {
35  init( part_n, p4.get( 0 ), p4.get( 1 ), p4.get( 2 ), p4.get( 3 ) );
36 }
37 
38 void EvtPhotonParticle::init( EvtId part_n, double e, double px, double py,
39  double pz )
40 {
41  _validP4 = true;
42  setp( e, px, py, pz );
43  setpart_num( part_n );
44 
45  setLifetime();
46 
47  //defere calculation of basis vectors untill they are needed!
48  _evalBasis = 0;
49 }
50 
52 {
53  if ( !_evalBasis ) {
54  _evalBasis = 1;
55  eps1.set( EvtComplex( 0.0, 0.0 ), EvtComplex( -1.0 / sqrt( 2.0 ), 0.0 ),
56  EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), EvtComplex( 0.0, 0.0 ) );
57  eps2.set( EvtComplex( 0.0, 0.0 ), EvtComplex( 1.0 / sqrt( 2.0 ), 0.0 ),
58  EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), EvtComplex( 0.0, 0.0 ) );
59 
60  // These are for photon along z axis. Rotate to get
61  // correct direction...
62 
63  double phi, theta;
64 
65  EvtVector4R p = this->getP4();
66 
67  double px = p.get( 1 );
68  double py = p.get( 2 );
69  double pz = p.get( 3 );
70 
71  phi = atan2( py, px );
72  theta = acos( pz / sqrt( px * px + py * py + pz * pz ) );
73  eps1.applyRotateEuler( phi, theta, -phi );
74  eps2.applyRotateEuler( phi, theta, -phi );
75  }
76 
77  EvtVector4C temp;
78 
79  switch ( i ) {
80  case 0:
81  temp = eps1;
82  break;
83  case 1:
84  temp = eps2;
85  break;
86  default:
87  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
88  << "EvtPhotonParticle.cc: Asked "
89  << "for state:" << i << endl;
90  ::abort();
91  break;
92  }
93 
94  return temp;
95 }
96 
98 {
99  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
100  << "EvtPhotonParticle.cc: Can not get "
101  << "state in photons restframe." << endl;
102  ;
103  ::abort();
104  return EvtVector4C();
105 }
106 
108 {
109  EvtVector4C eplus( 0.0, -1.0 / sqrt( 2.0 ),
110  EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
111  EvtVector4C eminus( 0.0, 1.0 / sqrt( 2.0 ),
112  EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
113 
114  //Really uggly have to cast away constness because the
115  //function epsParentPhoton caches the state vectors...
116  EvtVector4C e1 = ( (EvtParticle*)this )->epsParentPhoton( 0 );
117  EvtVector4C e2 = ( (EvtParticle*)this )->epsParentPhoton( 1 );
118 
119  EvtSpinDensity R;
120  R.setDim( 2 );
121 
122  R.set( 0, 0, ( eplus.conj() ) * e1 );
123  R.set( 0, 1, ( eplus.conj() ) * e2 );
124 
125  R.set( 1, 0, ( eminus.conj() ) * e1 );
126  R.set( 1, 1, ( eminus.conj() ) * e2 );
127 
128  return R;
129 }
130 
132  double beta,
133  double gamma ) const
134 {
135  EvtVector4C eplus( 0.0, -1.0 / sqrt( 2.0 ),
136  EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
137  EvtVector4C eminus( 0.0, 1.0 / sqrt( 2.0 ),
138  EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
139 
140  eplus.applyRotateEuler( alpha, beta, gamma );
141  eminus.applyRotateEuler( alpha, beta, gamma );
142 
143  //Really uggly have to cast away constness because the
144  //function epsParentPhoton caches the state vectors...
145  EvtVector4C e1 = ( (EvtParticle*)this )->epsParentPhoton( 0 );
146  EvtVector4C e2 = ( (EvtParticle*)this )->epsParentPhoton( 1 );
147 
148  EvtSpinDensity R;
149  R.setDim( 2 );
150 
151  R.set( 0, 0, ( eplus.conj() ) * e1 );
152  R.set( 0, 1, ( eplus.conj() ) * e2 );
153 
154  R.set( 1, 0, ( eminus.conj() ) * e1 );
155  R.set( 1, 1, ( eminus.conj() ) * e2 );
156 
157  return R;
158 }
void applyRotateEuler(double alpha, double beta, double gamma)
void set(int, const EvtComplex &)
Definition: EvtVector4C.hh:98
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
Definition: EvtId.hh:27
void setp(double e, double px, double py, double pz)
Definition: EvtParticle.hh:437
double get(int i) const
Definition: EvtVector4R.hh:162
void init(EvtId part_n, double e, double px, double py, double pz)
void setLifetime()
EvtSpinDensity rotateToHelicityBasis() const override
EvtVector4C epsParentPhoton(int i) override
const EvtVector4R & getP4() const
void init(EvtId part_n, const EvtVector4R &p4) override
EvtVector4C epsPhoton(int i) override
EvtVector4C conj() const
Definition: EvtVector4C.hh:202
void set(int i, int j, const EvtComplex &rhoij)
void setDim(int n)
void setpart_num(EvtId particle_number)
Definition: EvtParticle.hh:449