Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F7877167
D107.id446.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
D107.id446.diff
View Options
diff --git a/EvtGenBase/EvtParticle.hh b/EvtGenBase/EvtParticle.hh
--- a/EvtGenBase/EvtParticle.hh
+++ b/EvtGenBase/EvtParticle.hh
@@ -67,12 +67,12 @@
/**
* Returns polarization vector in the parents restframe for a photon.
*/
- virtual EvtVector4C epsParentPhoton( int i );
+ virtual EvtVector4C epsParentPhoton( int i ) const;
/**
* Returns polarization vector in the particles own restframe for a photon.
*/
- virtual EvtVector4C epsPhoton( int i );
+ virtual EvtVector4C epsPhoton( int i ) const;
/**
* Returns Dirac spinor in the parents restframe for a Dirac particle.
diff --git a/EvtGenBase/EvtPhotonParticle.hh b/EvtGenBase/EvtPhotonParticle.hh
--- a/EvtGenBase/EvtPhotonParticle.hh
+++ b/EvtGenBase/EvtPhotonParticle.hh
@@ -35,17 +35,14 @@
void init( EvtId part_n, const EvtVector4R& p4 ) override;
//Return polarization vectors
- EvtVector4C epsParentPhoton( int i ) override;
- EvtVector4C epsPhoton( int i ) override;
+ EvtVector4C epsParentPhoton( int i ) const override;
+ EvtVector4C epsPhoton( int i ) const override;
EvtSpinDensity rotateToHelicityBasis() const override;
EvtSpinDensity rotateToHelicityBasis( double alpha, double beta,
double gamma ) const override;
private:
- EvtVector4C eps1, eps2;
- int _evalBasis;
-
EvtPhotonParticle( const EvtPhotonParticle& photon );
EvtPhotonParticle& operator=( const EvtPhotonParticle& photon );
};
diff --git a/History.md b/History.md
--- a/History.md
+++ b/History.md
@@ -11,6 +11,9 @@
===
## R02-0X-00
+19 Feb 2024 Fernando Abudinen
+* D107: Implement const correctness for epsPhoton and epsParentPhoton
+
3 Feb 2024 John Back
* T230: Add EvtBcVPPHad model for Bc to Jpsi p pbar pi decays and generalised particle ordering
for EvtBcVHad decay files, courtesy of Aleksei Luchinsky, Dmitrii Pereima & Vanya Belyaev (LHCb).
diff --git a/src/EvtGenBase/EvtParticle.cpp b/src/EvtGenBase/EvtParticle.cpp
--- a/src/EvtGenBase/EvtParticle.cpp
+++ b/src/EvtGenBase/EvtParticle.cpp
@@ -632,7 +632,7 @@
return temp;
}
-EvtVector4C EvtParticle::epsParentPhoton( int i )
+EvtVector4C EvtParticle::epsParentPhoton( int i ) const
{
EvtVector4C temp;
printParticle();
@@ -644,7 +644,7 @@
return temp;
}
-EvtVector4C EvtParticle::epsPhoton( int i )
+EvtVector4C EvtParticle::epsPhoton( int i ) const
{
EvtVector4C temp;
printParticle();
diff --git a/src/EvtGenBase/EvtPhotonParticle.cpp b/src/EvtGenBase/EvtPhotonParticle.cpp
--- a/src/EvtGenBase/EvtPhotonParticle.cpp
+++ b/src/EvtGenBase/EvtPhotonParticle.cpp
@@ -43,45 +43,23 @@
setpart_num( part_n );
setLifetime();
-
- //defere calculation of basis vectors untill they are needed!
- _evalBasis = 0;
}
-EvtVector4C EvtPhotonParticle::epsParentPhoton( int i )
+EvtVector4C EvtPhotonParticle::epsParentPhoton( int i ) const
{
- if ( !_evalBasis ) {
- _evalBasis = 1;
- eps1.set( EvtComplex( 0.0, 0.0 ), EvtComplex( -1.0 / sqrt( 2.0 ), 0.0 ),
- EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), EvtComplex( 0.0, 0.0 ) );
- eps2.set( EvtComplex( 0.0, 0.0 ), EvtComplex( 1.0 / sqrt( 2.0 ), 0.0 ),
- EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), EvtComplex( 0.0, 0.0 ) );
-
- // These are for photon along z axis. Rotate to get
- // correct direction...
-
- double phi, theta;
-
- EvtVector4R p = this->getP4();
-
- double px = p.get( 1 );
- double py = p.get( 2 );
- double pz = p.get( 3 );
-
- phi = atan2( py, px );
- theta = acos( pz / sqrt( px * px + py * py + pz * pz ) );
- eps1.applyRotateEuler( phi, theta, -phi );
- eps2.applyRotateEuler( phi, theta, -phi );
- }
-
- EvtVector4C temp;
+ EvtVector4C eps;
switch ( i ) {
case 0:
- temp = eps1;
+ eps.set( EvtComplex( 0.0, 0.0 ),
+ EvtComplex( -1.0 / sqrt( 2.0 ), 0.0 ),
+ EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ),
+ EvtComplex( 0.0, 0.0 ) );
break;
case 1:
- temp = eps2;
+ eps.set( EvtComplex( 0.0, 0.0 ), EvtComplex( 1.0 / sqrt( 2.0 ), 0.0 ),
+ EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ),
+ EvtComplex( 0.0, 0.0 ) );
break;
default:
EvtGenReport( EVTGEN_ERROR, "EvtGen" )
@@ -90,11 +68,21 @@
::abort();
break;
}
+ // These are for photon along z axis. Rotate to get
+ // correct direction...
+
+ const double px = this->getP4().get( 1 );
+ const double py = this->getP4().get( 2 );
+ const double pz = this->getP4().get( 3 );
- return temp;
+ const double phi = atan2( py, px );
+ const double theta = acos( pz / sqrt( px * px + py * py + pz * pz ) );
+ eps.applyRotateEuler( phi, theta, -phi );
+
+ return eps;
}
-EvtVector4C EvtPhotonParticle::epsPhoton( int )
+EvtVector4C EvtPhotonParticle::epsPhoton( int ) const
{
EvtGenReport( EVTGEN_ERROR, "EvtGen" )
<< "EvtPhotonParticle.cc: Can not get "
@@ -106,15 +94,13 @@
EvtSpinDensity EvtPhotonParticle::rotateToHelicityBasis() const
{
- EvtVector4C eplus( 0.0, -1.0 / sqrt( 2.0 ),
- EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
- EvtVector4C eminus( 0.0, 1.0 / sqrt( 2.0 ),
- EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
+ const EvtVector4C eplus( 0.0, -1.0 / sqrt( 2.0 ),
+ EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
+ const EvtVector4C eminus( 0.0, 1.0 / sqrt( 2.0 ),
+ EvtComplex( 0.0, -1.0 / sqrt( 2.0 ) ), 0.0 );
- //Really uggly have to cast away constness because the
- //function epsParentPhoton caches the state vectors...
- EvtVector4C e1 = ( (EvtParticle*)this )->epsParentPhoton( 0 );
- EvtVector4C e2 = ( (EvtParticle*)this )->epsParentPhoton( 1 );
+ const EvtVector4C e1 = this->epsParentPhoton( 0 );
+ const EvtVector4C e2 = this->epsParentPhoton( 1 );
EvtSpinDensity R;
R.setDim( 2 );
@@ -140,10 +126,8 @@
eplus.applyRotateEuler( alpha, beta, gamma );
eminus.applyRotateEuler( alpha, beta, gamma );
- //Really uggly have to cast away constness because the
- //function epsParentPhoton caches the state vectors...
- EvtVector4C e1 = ( (EvtParticle*)this )->epsParentPhoton( 0 );
- EvtVector4C e2 = ( (EvtParticle*)this )->epsParentPhoton( 1 );
+ const EvtVector4C e1 = this->epsParentPhoton( 0 );
+ const EvtVector4C e2 = this->epsParentPhoton( 1 );
EvtSpinDensity R;
R.setDim( 2 );
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 2:52 PM (14 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3804386
Default Alt Text
D107.id446.diff (6 KB)
Attached To
D107: Implemented const correctness for epsPhoton and epsParentPhoton
Event Timeline
Log In to Comment