/*************************************************************************** * musrSim - the program for the simulation of (mainly) muSR instruments. * * More info on http://lmu.web.psi.ch/simulation/index.html . * * musrSim is based od Geant4 (http://geant4.web.cern.ch/geant4/) * * * * Copyright (C) 2009 by Paul Scherrer Institut, 5232 Villigen PSI, * * Switzerland * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * ***************************************************************************/ #include "musrParameters.hh" // #include "musrErrorMessage.hh" - musrErrorMessage class can not be used inside "musrParameters" constructor, because // musrErrorMessage is crated later! #include "CLHEP/Units/SystemOfUnits.h" #include #include #include musrParameters::musrParameters(G4String steeringFileName) { pointerToParameters = this; boolG4RegionRequested = false; mySteeringFileName = steeringFileName; myStopFileName = mySteeringFileName; myStopFileName.replace(myStopFileName.length()-3,myStopFileName.length()-1,"stop"); myRandomNumberFileName = mySteeringFileName; myRandomNumberFileName.replace(myRandomNumberFileName.length()-3,myRandomNumberFileName.length()-1,"rndm"); // Read in the parameters, which have to be known before the detector construction is run // (and therefore the parameters can not be read in in the musrDetectorConstruction.cc class). FILE *fSteeringFile=fopen(steeringFileName.c_str(),"r"); if (fSteeringFile==nullptr) { G4cout<<"musrParameters::musrParameters: steeringFileName=\""<> command) { // First find out how many events will be generated (needs to be known at an early stage, if the // field is to be set in steps): if (command=="/run/beamOn") { std::string eventCount; if (!(lineStream >> eventCount)) { reportParseError("/run/beamOn: expected an integer event count"); } G4int numberOfEvents = 0; const char* first = eventCount.data(); const char* last = first + eventCount.size(); const std::from_chars_result result = std::from_chars(first,last,numberOfEvents); if (result.ec!=std::errc() || result.ptr!=last || numberOfEvents<0) { reportParseError("/run/beamOn: invalid event count '"+eventCount+"'"); } musrParameters::nrOfEventsToBeGenerated = numberOfEvents; } if (command.compare(0,5,"/gps/")==0) { musrParameters::boolG4GeneralParticleSource = true; G4cout<<"\n========================================================================"<> operation)) { reportParseError("/musr/command: expected an operation"); } // if (strcmp(tmpString1,"G4GeneralParticleSource")==0){ // if (strcmp(tmpString2,"true")==0){ musrParameters::boolG4GeneralParticleSource = true; } // } if (operation=="G4OpticalPhotons") { std::string enabled; if (!(lineStream >> enabled) || (enabled!="true" && enabled!="false")) { reportParseError("G4OpticalPhotons: expected 'true' or 'false'"); } if (enabled=="true") musrParameters::boolG4OpticalPhotons = true; } if (operation=="G4OpticalPhotonsUnprocess") { std::string enabled; if (!(lineStream >> enabled) || (enabled!="true" && enabled!="false")) { reportParseError("G4OpticalPhotonsUnprocess: expected 'true' or 'false'"); } if (enabled=="true") musrParameters::boolG4OpticalPhotonsUnprocess = true; } if (operation=="region") { boolG4RegionRequested = true; } if (operation=="construct" && boolG4RegionRequested) { std::string volumeType; std::string volumeName; if (!(lineStream >> volumeType >> volumeName)) { reportParseError("construct: expected a volume type and name"); } G4cout<<"musrParameters.cc: User requests to construct a detector volume "<