37 #include <tools/aida_ntuple>
38 #include <tools/rcsv_histo>
43 using namespace G4Analysis;
55 void* ReadObject(std::istream& hnFile,
60 tools::rcsv::histo handler(hnFile);
61 std::string objectTypeInFile;
64 if ( ! handler.read(
G4cout, objectTypeInFile,
object, verbose) ) {
68 <<
"Cannot get "<< objectType <<
" in file " << fileName;
69 G4String inFunctionFull =
"G4CsvAnalysisReader::";
70 inFunctionFull.
append(inFunction);
74 if ( objectTypeInFile != objectType ) {
78 <<
"Object type read in "<< fileName
79 <<
" does not match" <<
G4endl;
80 G4String inFunctionFull =
"G4CsvAnalysisReader::";
81 inFunctionFull.
append(inFunction);
94 if ( fgInstance ==
nullptr ) {
105 fNtupleManager(nullptr),
106 fFileManager(nullptr)
112 <<
"G4CsvAnalysisReader already exists."
113 <<
"Cannot create another instance.";
114 G4Exception(
"G4CsvAnalysisReader::G4CsvAnalysisReader()",
146 G4bool isUserFileName)
const
148 if ( isUserFileName ) {
161 auto finalResult =
true;
164 finalResult = finalResult &&
result;
167 finalResult = finalResult &&
result;
188 auto h1FileName =
GetHnFileName(
"h1", h1Name, fileName, isUserFileName);
189 std::ifstream hnFile(h1FileName);
190 if ( ! hnFile.is_open() ) {
192 description <<
" " <<
"Cannot open file " << h1FileName;
200 ->
Message(
"open",
"read file", h1FileName);
204 = ReadObject(hnFile, tools::histo::h1d::s_class(), h1FileName,
"ReadH1Impl");
230 auto h2FileName =
GetHnFileName(
"h2", h2Name, fileName, isUserFileName);
231 std::ifstream hnFile(h2FileName);
232 if ( ! hnFile.is_open() ) {
234 description <<
" " <<
"Cannot open file " << h2FileName;
242 ->
Message(
"open",
"read file", h2FileName);
246 = ReadObject(hnFile, tools::histo::h2d::s_class(), h2FileName,
"ReadH2Impl");
249 auto h2 =
static_cast<tools::histo::h2d*
>(object);
272 auto h3FileName =
GetHnFileName(
"h3", h3Name, fileName, isUserFileName);
273 std::ifstream hnFile(h3FileName);
274 if ( ! hnFile.is_open() ) {
276 description <<
" " <<
"Cannot open file " << h3FileName;
284 ->
Message(
"open",
"read file", h3FileName);
288 = ReadObject(hnFile, tools::histo::h3d::s_class(), h3FileName,
"ReadH3Impl");
291 auto h3 =
static_cast<tools::histo::h3d*
>(object);
315 std::ifstream hnFile(p1FileName);
316 if ( ! hnFile.is_open() ) {
318 description <<
" " <<
"Cannot open file " << p1FileName;
326 ->
Message(
"open",
"read file", p1FileName);
330 = ReadObject(hnFile, tools::histo::p1d::s_class(), fileName,
"ReadP1Impl");
333 auto p1 =
static_cast<tools::histo::p1d*
>(object);
357 std::ifstream hnFile(p2FileName);
358 if ( ! hnFile.is_open() ) {
360 description <<
" " <<
"Cannot open file " << p2FileName;
368 ->
Message(
"open",
"read file", p2FileName);
372 = ReadObject(hnFile, tools::histo::p2d::s_class(), p2FileName,
"ReadP2Impl");
375 auto p2 =
static_cast<tools::histo::p2d*
>(object);
402 if ( ! isUserFileName ) {
virtual G4int ReadH3Impl(const G4String &h3Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
const G4AnalysisVerbose * GetVerboseL2() const
std::ostringstream G4ExceptionDescription
G4AnalysisManagerState fState
G4String GetNtupleFileName(const G4String &ntupleName) const
G4CsvAnalysisReader(G4bool isMaster=true)
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
static G4CsvAnalysisReader * Instance()
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
std::ifstream * GetRFile(const G4String &fileName) const
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
G4String GetHnFileName(const G4String &hnType, const G4String &hnName, const G4String &baseFileName, G4bool isUserFileName) const
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
G4String GetHnFileName(const G4String &hnType, const G4String &hnName) const
void SetFileManager(G4BaseFileManager *fileManager)
static G4CsvAnalysisReader * fgMasterInstance
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
G4CsvRFileManager * fFileManager
G4double G4ParticleHPJENDLHEData::G4double result
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4int SetNtuple(G4TRNtupleDescription< TNTUPLE > *rntupleDescription)
virtual G4bool OpenRFile(const G4String &fileName)
virtual ~G4CsvAnalysisReader()
static G4ThreadLocal G4CsvAnalysisReader * fgInstance
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
G4GLOB_DLL std::ostream G4cout
G4bool GetIsMaster() const
G4String & append(const G4String &)
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
const G4AnalysisVerbose * GetVerboseL1() const
G4CsvRNtupleManager * fNtupleManager