43 #include <tools/aida_ntuple>
44 #include <tools/rcsv_histo>
61 void* ReadObject(std::istream& hnFile,
66 tools::rcsv::histo handler(hnFile);
67 std::string objectTypeInFile;
70 if ( ! handler.read(
G4cout, objectTypeInFile,
object, verbose) ) {
74 <<
"Cannot get "<< objectType <<
" in file " << fileName;
75 G4String inFunctionFull =
"G4CsvAnalysisReader::";
76 inFunctionFull.
append(inFunction);
80 if ( objectTypeInFile != objectType ) {
84 <<
"Object type read in "<< fileName
85 <<
" does not match" <<
G4endl;
86 G4String inFunctionFull =
"G4CsvAnalysisReader::";
87 inFunctionFull.
append(inFunction);
100 if ( fgInstance == 0 ) {
123 <<
"G4CsvAnalysisReader already exists."
124 <<
"Cannot create another instance.";
125 G4Exception(
"G4CsvAnalysisReader::G4CsvAnalysisReader()",
167 G4bool isUserFileName)
const
169 if ( isUserFileName ) {
182 G4bool finalResult =
true;
185 finalResult = finalResult && result;
188 finalResult = finalResult && result;
191 finalResult = finalResult && result;
212 std::ifstream hnFile(h1FileName);
213 if ( ! hnFile.is_open() ) {
215 description <<
" " <<
"Cannot open file " << h1FileName;
223 ->
Message(
"open",
"read file", h1FileName);
227 = ReadObject(hnFile, tools::histo::h1d::s_class(), h1FileName,
"ReadH1Impl");
230 tools::histo::h1d* h1
231 =
static_cast<tools::histo::h1d*
>(object);
254 std::ifstream hnFile(h2FileName);
255 if ( ! hnFile.is_open() ) {
257 description <<
" " <<
"Cannot open file " << h2FileName;
265 ->
Message(
"open",
"read file", h2FileName);
269 = ReadObject(hnFile, tools::histo::h2d::s_class(), h2FileName,
"ReadH2Impl");
272 tools::histo::h2d* h2
273 =
static_cast<tools::histo::h2d*
>(object);
296 std::ifstream hnFile(h3FileName);
297 if ( ! hnFile.is_open() ) {
299 description <<
" " <<
"Cannot open file " << h3FileName;
307 ->
Message(
"open",
"read file", h3FileName);
311 = ReadObject(hnFile, tools::histo::h3d::s_class(), h3FileName,
"ReadH3Impl");
314 tools::histo::h3d* h3
315 =
static_cast<tools::histo::h3d*
>(object);
338 std::ifstream hnFile(p1FileName);
339 if ( ! hnFile.is_open() ) {
341 description <<
" " <<
"Cannot open file " << p1FileName;
349 ->
Message(
"open",
"read file", p1FileName);
353 = ReadObject(hnFile, tools::histo::p1d::s_class(), fileName,
"ReadP1Impl");
356 tools::histo::p1d*
p1
357 =
static_cast<tools::histo::p1d*
>(object);
380 std::ifstream hnFile(p2FileName);
381 if ( ! hnFile.is_open() ) {
383 description <<
" " <<
"Cannot open file " << p2FileName;
391 ->
Message(
"open",
"read file", p2FileName);
395 = ReadObject(hnFile, tools::histo::p2d::s_class(), p2FileName,
"ReadP2Impl");
398 tools::histo::p2d*
p2
399 =
static_cast<tools::histo::p2d*
>(object);
425 if ( ! isUserFileName ) {
431 std::ifstream* ntupleFile
435 tools::rcsv::ntuple* rntuple =
new tools::rcsv::ntuple(*ntupleFile);
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
void SetP1Manager(G4VP1Manager *p1Manager)
void SetP2Manager(G4VP2Manager *p2Manager)
std::ostringstream G4ExceptionDescription
G4String GetNtupleFileName(const G4String &ntupleName) const
static G4CsvAnalysisReader * Instance()
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName)
G4H2ToolsManager * fH2Manager
virtual ~G4CsvAnalysisReader()
G4AnalysisManagerState fState
G4String GetHnFileName(const G4String &hnType, const G4String &hnName) const
virtual G4int ReadH3Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName)
const G4AnalysisVerbose * GetVerboseL2() const
void SetH3Manager(G4VH3Manager *h3Manager)
virtual G4int ReadP2Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName)
G4GLOB_DLL std::ostream G4cout
virtual G4int ReadP1Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName)
const G4AnalysisVerbose * GetVerboseL4() const
std::ifstream * GetRFile(const G4String &fileName) const
G4P2ToolsManager * fP2Manager
G4CsvRFileManager * fFileManager
static G4ThreadLocal G4CsvAnalysisReader * fgInstance
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
G4String GetHnFileName(const G4String &hnType, const G4String &hnName, const G4String &baseFileName, G4bool isUserFileName) const
G4int SetNtuple(G4CsvRNtupleDescription *rntupleDescription)
G4CsvRNtupleManager * fNtupleManager
static G4CsvAnalysisReader * fgMasterInstance
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetH1Manager(G4VH1Manager *h1Manager)
G4P1ToolsManager * fP1Manager
G4CsvAnalysisReader(G4bool isMaster=true)
G4String & append(const G4String &)
G4bool GetIsMaster() const
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, G4bool isUserFileName)
virtual G4bool OpenRFile(const G4String &fileName)
G4H1ToolsManager * fH1Manager
void SetH2Manager(G4VH2Manager *h2Manager)
virtual G4int ReadH2Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName)
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
G4H3ToolsManager * fH3Manager
const G4AnalysisVerbose * GetVerboseL1() const
void SetFileManager(G4BaseFileManager *fileManager)