Runnumber corret for provided command line paths
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
#include <regex>
|
||||||
#include "musrDetectorConstruction.hh"
|
#include "musrDetectorConstruction.hh"
|
||||||
#include "musrPhysicsList.hh"
|
#include "musrPhysicsList.hh"
|
||||||
#include "musrPrimaryGeneratorAction.hh"
|
#include "musrPrimaryGeneratorAction.hh"
|
||||||
@ -76,9 +77,13 @@ int main(int argc,char** argv) {
|
|||||||
|
|
||||||
// UserInitialization classes (mandatory)
|
// UserInitialization classes (mandatory)
|
||||||
// musrDetectorConstruction* musrdetector = new musrDetectorConstruction;
|
// musrDetectorConstruction* musrdetector = new musrDetectorConstruction;
|
||||||
|
//Allow for argv[1] generic paths and only extract the runnumber before .mac
|
||||||
if (argc>1) {
|
if (argc>1) {
|
||||||
G4int myRunNr=atoi(argv[1]); // Get the run number from the name of the
|
std::regex pattern(R"((\d+)(?=(?=[^/]*\.mac$)))"); // for an input like /some/path987/1234.mac for argv[1]. Matches last number (1234) before ".mac"
|
||||||
// parameter file, if it starts with a number.
|
std::smatch match;
|
||||||
|
G4int myRunNr = 0;
|
||||||
|
std::string argv1str(argv[1]);
|
||||||
|
if (std::regex_search(argv1str, match, pattern)) myRunNr = G4int(std::stoi(match.str(1)));
|
||||||
if (myRunNr>0) {runManager->SetRunIDCounter(myRunNr);}
|
if (myRunNr>0) {runManager->SetRunIDCounter(myRunNr);}
|
||||||
// musrdetector->SetInputParameterFileName(argv[1]);
|
// musrdetector->SetInputParameterFileName(argv[1]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user