Problem 1120 - G4PhotoElectricAngularGeneratorSauterGavrila.cc returns G4Double
Summary: G4PhotoElectricAngularGeneratorSauterGavrila.cc returns G4Double
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/electromagnetic/lowenergy (show other problems)
Version: 9.3
Hardware: PC Linux
: P5 trivial
Assignee: Sebastien Incerti
URL:
: 1124 1142 1144 (view as problem list)
Depends on:
Blocks:
 
Reported: 2010-06-14 23:08 CEST by mario
Modified: 2010-09-17 09:05 CEST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description mario 2010-06-14 23:08:29 CEST
Hi,

I have the following error compiling with g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3 :

---------------
src/G4PhotoElectricAngularGeneratorSauterGavrila.cc:82: error: conversion from ‘G4double’ to non-scalar type ‘G4ThreeVector’ requested
make[2]: *** [/home/malemi/geant4.9.3.p01/tmp/Linux-g++/G4emlowenergy/G4PhotoElectricAngularGeneratorSauterGavrila.o] Error 1
-------------------------------

The file seems to return a G4Double actually, and not a Vector. Nonetheless in previous G4 releases had the same code and no error.... ? Can it be a mistake of mine?

Mario
Comment 1 Gabriele Cosmo 2010-06-17 09:12:37 CEST
The compilation error you get is due to the fact you're using a version of CLHEP which
is not the version supported for release 9.3. Please, use CLHEP-2.0.4.5.
New versions of CLHEP will be supported in forthcoming releases of Geant4.
Comment 2 Gabriele Cosmo 2010-06-24 08:57:24 CEST
*** Problem 1124 has been marked as a duplicate of this problem. ***
Comment 3 mario 2010-06-24 11:12:34 CEST
Sorry for reopening it. I am using CLHEP 2.0.5.0.b01, it's a brand new installation, everything should be up to date.

Regards,
Mario
Comment 4 mario 2010-06-24 11:18:55 CEST
sorry, I got it... one should use the *old* version of CLHEP, not the newest... sorry again
Comment 5 Oleg Shirokobrod 2010-06-24 11:58:10 CEST
CLHEP-2.0.4.5. just hides this bug allowing conversion G4double to G4ThreeVector. CLHEP-2.1.0.0.bo1 has different CTORs for G4ThreeVector which do not allow such conversion.

Here you are a snippet of the problem code

G4ThreeVector G4PhotoElectricAngularGeneratorSauterGavrila::GetPhotoElectronDirection(const G4ThreeVector& direction, const G4double eKineticEnergy, const G4ThreeVector&, const G4int) const
{
...
 73 G4double costeta = 1.;
...
 80 if (gamma > 5.) {
 81     G4ThreeVector direction (sinteta*cosphi, sinteta*sinphi, costeta);
 82     return costeta;
 83 }
...
}
Inside the 'if' block a new local variable 'direction' of correct return type is defined and never used in the block. G4double value is returned at the line 82.
I think there is still the bug which does not depend on CLHEP.
Comment 6 mario 2010-06-24 14:35:05 CEST
couldn't agree more.... it's good practice return a Vector instead of a double, when you declare that your method is going to return a Vector and not a double:))
mario
Comment 7 Jacques Goldberg 2010-09-05 00:14:53 CEST
Installing the current dev version under Fedora 13 with gcc4.4.4-10.
Same problem met of course, G4PhotoElectricAngularGeneratorSauterGavrila.cc line 82 returns G4Double.

I have edited as follows to correct the error:
 80   if (gamma > 5.) {
     81    G4ThreeVector direction (sinteta*cosphi, sinteta*sinphi, costeta);
     82 //   return costeta;
     83 //   JG 04/09/10
     84    return direction;
     85   }

The bug is to try to return costeta instead of returning direction , as done for the non trivial case gamma < 5. :
    102   G4ThreeVector photoelectrondirection (sinteta*cosphi, sinteta*sinphi        , costeta);
    103   photoelectrondirection.rotateUz(direction);
    104   return photoelectrondirection;
Line numbers 102-104 are shifted by 2 w.r.t. the original file because I added 82,84.
Comment 8 Sebastien Incerti 2010-09-05 11:06:39 CEST
Thank you so much Jacques. Your fix was added to Geant4 CVS.
Comment 9 Gabriele Cosmo 2010-09-10 09:10:05 CEST
*** Problem 1142 has been marked as a duplicate of this problem. ***
Comment 10 Gabriele Cosmo 2010-09-17 09:05:12 CEST
*** Problem 1144 has been marked as a duplicate of this problem. ***