Fatal error: g4csv.hh: No such file or directory


I have been using Geant4 10.6 till now and decided to upgrade to Geant4 11. My older source codes that used to work properly on 10.6 and now encountering this error:

/home/sanchit/Softwares/G4_Work/New_N_200V_45/source/include/Analysis.hh:35:10: fatal error: g4csv.hh: No such file or directory
   35 | #include "g4csv.hh"
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/task.dir/build.make:118: CMakeFiles/task.dir/src/EventAction.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/task.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Can I please get a hint about the changes in this newer version that would fix this issue? My Analysis.hh is below:

#ifndef MyAnalysis_h
#define MyAnalysis_h 1

//#include "g4root.hh"
#include "g4csv.hh"
//#include "g4xml.hh"


Thanks very much!

The release notes for Geant4 11.0 indicate that the g4csv.hh header has been depreciated.

I haven’t done it myself, but I believe the new approach would be:

#ifndef MyAnalysis_h
#define MyAnalysis_h 1

#include "G4CsvAnalysisManager.hh"

using G4AnalysisManager = G4CsvAnalysisManager;


You can find the documentation here.


Dear @sanchitsharma,

I believe @JDecunha is almost right in the sense that your code seems to be outdated and not v11 ready -yet-.

You can have a proper look at example B4 for details but if you look at the RunAction class you will notice the following:

#include "G4AnalysisManager.hh"
void RunAction::BeginOfRunAction(const G4Run* /*run*/)
  //inform the runManager to save random number seed
  // Get analysis manager
  auto analysisManager = G4AnalysisManager::Instance();
  // Open an output file
  G4String fileName = "B4.root";
  // Other supported output types:
  // G4String fileName = "B4.csv";
  // G4String fileName = "B4.hdf5";
  // G4String fileName = "B4.xml";
  G4cout << "Using " << analysisManager->GetType() << G4endl;

meaning now instead of having a VERY SHORT analysis header (basically one #include) now this is controlled with the extension of the output file.

Hope this helps.