Skip to content

Commit 938c6d8

Browse files
authored
Merge pull request #165 from rest-for-physics/nkx111-patch-2
TRestRun::TRestRun(string) constructor supports both root file and rml file initialization.
2 parents b05be52 + 3e629ab commit 938c6d8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

source/framework/core/inc/TRestRun.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ class TRestRun : public TRestMetadata {
5959
int fEventIndexCounter = 0; //!
6060
bool fHangUpEndFile = false; //!
6161
bool fFromRML = false; //!
62+
63+
void InitFromConfigFile();
64+
6265
private:
6366
string ReplaceMetadataMember(const string instr);
6467

6568
public:
6669
/// REST run class
6770
void Initialize();
68-
void InitFromConfigFile();
6971

7072
// file operation
7173
void OpenInputFile(int i);
@@ -239,7 +241,7 @@ class TRestRun : public TRestMetadata {
239241

240242
// Construtor & Destructor
241243
TRestRun();
242-
TRestRun(string rootfilename);
244+
TRestRun(string filename);
243245
~TRestRun();
244246

245247
ClassDef(TRestRun, 4);

source/framework/core/src/TRestRun.cxx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,16 @@ ClassImp(TRestRun);
3838

3939
TRestRun::TRestRun() { Initialize(); }
4040

41-
TRestRun::TRestRun(string rootfilename) {
42-
Initialize();
43-
OpenInputFile(rootfilename);
41+
TRestRun::TRestRun(string filename) {
42+
if (filename.find(".root") != string::npos) {
43+
Initialize();
44+
OpenInputFile(filename);
45+
} else if (filename.find(".rml") != string::npos) {
46+
Initialize();
47+
LoadConfigFromFile(filename);
48+
} else {
49+
ferr << "TRestRun::TRestRun(): input file error!" << endl;
50+
}
4451
}
4552

4653
TRestRun::~TRestRun() {

0 commit comments

Comments
 (0)