Skip to content

Commit 5c51ec5

Browse files
authored
Merge pull request #115 from rest-for-physics/lobis-remote-file
Remote geometry file
2 parents d4c4d95 + 09e50f0 commit 5c51ec5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/TRestGeant4Metadata.cxx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,14 @@ void TRestGeant4Metadata::InitFromConfigFile() {
801801
cout << "\"gdmlFile\" parameter is not defined!" << endl;
802802
exit(1);
803803
}
804+
if (TRestTools::isURL(fGdmlFilename.Data())) {
805+
fGeometryPath = "";
806+
fGdmlFilename = TRestTools::DownloadRemoteFile(fGdmlFilename.Data());
807+
if (fGdmlFilename == "") {
808+
cout << "Error downloading geometry file from URL: " << fGdmlFilename << endl;
809+
exit(1);
810+
}
811+
}
804812

805813
fGeometryPath = GetParameter("geometryPath", "");
806814

@@ -818,7 +826,7 @@ void TRestGeant4Metadata::InitFromConfigFile() {
818826
// if "gdmlFile" is purely a file (without any path) and "geometryPath" is
819827
// defined, we recombine them together
820828
if ((((string)fGdmlFilename).find_first_not_of("./~") == 0 ||
821-
((string)fGdmlFilename).find("/") == string::npos) &&
829+
((string)fGdmlFilename).find('/') == string::npos) &&
822830
fGeometryPath != "") {
823831
if (fGeometryPath[fGeometryPath.Length() - 1] == '/') {
824832
fGdmlFilename = fGeometryPath + GetParameter("gdmlFile");
@@ -945,7 +953,7 @@ Double_t TRestGeant4Metadata::GetCosmicIntensityInCountsPerSecond() const {
945953

946954
Double_t TRestGeant4Metadata::GetEquivalentSimulatedTime() const {
947955
const auto countsPerSecond = GetCosmicIntensityInCountsPerSecond();
948-
const auto seconds = fNEvents / countsPerSecond;
956+
const auto seconds = double(fNEvents) / countsPerSecond;
949957
return seconds;
950958
}
951959

0 commit comments

Comments
 (0)