Issues with "geant4\examples\extended\runAndEvent\RE03"

_Geant4 Version:_11.3.1 (21-March-2025)
_Operating System:_Windows 11 Enterprise
_Compiler/Version:_Microsoft Visual Studio Community 2022 (2) (64-bit) - Version 17.12.1
_CMake Version:_3.31.6


I am trying to run “geant4\examples\extended\runAndEvent\RE03”, but got two issues in “RE03UserScoreWriter.cc”:

  1. For this line " ofile << voxelIndex << " " << doseValue << G4endl;", VS complained “no operator “<<” matches these operands”.
    how to fix:
    ofile << voxelIndex << " " << doseValue.GetSumW() << G4endl;
  2. For this line, “std::map<G4int, G4double*>::iterator value = score->find(idx);” VS complained “identifier “score” is undefined”.
    how to fix:
    auto value = scoreMap->find(idx);
    if (value != scoreMap->end()) {
    projxy[y] += value->second->sum_w();
    }

Looks like this example has not been run for a long time. Though ChatGPT was able to find the solutions quickly, at the same time, I think the sample code should be updated.

Could you confirm this is the example from Geant4 11.3.1, and that you have not made modifications to it please? I can’t find a line matching the first one, and in the second case, there is an identifier score:

then used here:

Our nightly tests are building and running this example, with Windows and VS as follows:

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.26100.
-- The C compiler identification is MSVC 19.40.33808.0
-- The CXX compiler identification is MSVC 19.40.33808.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features

Could you post the output you are getting from CMake please?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.