diff --git a/core/config/CbmConfigBase.h b/core/config/CbmConfigBase.h index 81e28528262fd8b302e4b9ba37fd74cd15708c96..b35f0f26e51401b93c46fd0dd035fd877a4784c1 100644 --- a/core/config/CbmConfigBase.h +++ b/core/config/CbmConfigBase.h @@ -94,7 +94,9 @@ public: if (pt.empty() /* && !pt.data().empty()*/) { if (key.back() == '.') key.pop_back(); LOG(debug) << "CbmConfig: Insert: " << key; - if (key.find("#") > key.size()) //used for comments + if (key.find("#") < key.size()) //used for comments + return; + else treeSet.insert(key); } @@ -147,7 +149,9 @@ public: std::regex_search(s, match, rgx); std::string varString = match[0]; std::string varName = std::regex_replace(varString, std::regex("\\$|\\{|\\}"), ""); - s.replace(s.find(varString), varString.size(), gSystem->Getenv(varName.c_str())); + const char* varValue = gSystem->Getenv(varName.c_str()); + if (!varValue) varValue = ""; + s.replace(s.find(varString), varString.size(), varValue); } return s; } diff --git a/macro/run/config.json b/macro/run/config.json index b81fc8d4bcfbdc497bb03c5e9df8e1bed84ffa40..c018b9e83bfe582b323289c8730a2ac0d4e814b3 100644 --- a/macro/run/config.json +++ b/macro/run/config.json @@ -15,7 +15,10 @@ "beamP": 12.0, "beamStartZ": -1.0} ], - "output.path": "", + "output": { + "path": "test", + "overwrite": false + }, "target": { "material": "Gold", "thickness": 0.025, @@ -31,7 +34,7 @@ "position": { "x": 0.0, "y": 0.0, - "z": 0.0, + "zFocus": 0.0, "sigmaX": 0.1, "sigmaY": 0.1 }, @@ -58,18 +61,18 @@ "position": { "x": 0.0, "y": 0.0, - "z": 40.0 + "z": 0.0 } }, "subsystems": { - "magnet": "v20a", - "pipe": "v16b_1e", + "magnet": "v21a", + "pipe": "v16e_1e", "mvd": "v20c_tr", - "sts": "v19a", - "rich": "v17a_1e", - "trd": "v20b_1e", - "tof": "v20b_1e", - "psd": "v20a", + "sts": "v20a", + "rich": "v21a", + "trd": "v20c_1e", + "tof": "v20c_1e", + "psd": "v20c", "platform": "v13a" } }, diff --git a/sim/response/base/CbmDigitizationConfig.cxx b/sim/response/base/CbmDigitizationConfig.cxx index 06f9c915f13ec84015513f5b7d020c2ce53251ed..980771d2327a5ed2cecb66a9567a1a941fd8f7ed 100644 --- a/sim/response/base/CbmDigitizationConfig.cxx +++ b/sim/response/base/CbmDigitizationConfig.cxx @@ -93,7 +93,10 @@ bool CbmDigitizationConfig::SetIO(CbmDigitization& obj, const pt::ptree& moduleT obj.AddInput(id, path + ".tra.root", rate, treeAccessMode); } if (parameterSource) { - if (!parametersSet) { parametersPath = path; } + if (!parametersSet) { + parametersPath = path; + parametersSet = true; + } else { LOG(error) << "CbmDigitizationConfig: only one parameter source is allowed!"; return false; @@ -105,10 +108,11 @@ bool CbmDigitizationConfig::SetIO(CbmDigitization& obj, const pt::ptree& moduleT string outputPath = GetStringValue(moduleTree, "output.path", paths.at(0)); bool overwrite = moduleTree.get<bool>("output.overwrite", false); - if (!parametersSet) parametersPath = paths.at(0); + if (!parametersSet) parametersPath = outputPath; LOG(info) << "CbmDigitizationConfig: Parameter source:\n" << parametersPath; obj.SetParameterRootFile(parametersPath + ".par.root"); LOG(info) << "CbmDigitizationConfig: Output path:\n" << outputPath; + if (overwrite) LOG(info) << "CbmDigitizationConfig: Overwrite output!"; obj.SetOutputFile(outputPath + ".raw.root", overwrite); obj.SetMonitorFile((outputPath + ".moni_digi.root").c_str()); @@ -125,7 +129,7 @@ bool CbmDigitizationConfig::SetDigitizationParameters(CbmDigitization& obj, cons auto startTime = moduleTree.get_optional<float>("startTime"); if (eventMode) { - if (storeAllTimeSlices || timeSliceLength || startTime) { + if (storeAllTimeSlices || timeSliceLength) { LOG(error) << "CbmDigitizationConfig: time slice settings should not be used in event mode!"; return false; } @@ -154,8 +158,7 @@ bool CbmDigitizationConfig::SetGeometry(CbmDigitization& obj, const pt::ptree& m if (modulesToDeactivate) for (auto& module : modulesToDeactivate.get()) - if (module.first != "") obj.Deactivate(stringToECbmModuleId(module.first)); - + if (module.first != "") obj.Deactivate(stringToECbmModuleId(module.second.get<string>(""))); return true; } diff --git a/sim/transport/steer/CbmTransportConfig.cxx b/sim/transport/steer/CbmTransportConfig.cxx index 894255750c66fb6c3cc811e6422b59ac1e249d89..bcf54bcbc1564ff340f9e301ac63081ce52c586c 100644 --- a/sim/transport/steer/CbmTransportConfig.cxx +++ b/sim/transport/steer/CbmTransportConfig.cxx @@ -26,6 +26,7 @@ CbmTransportConfig::TagSet_t CbmTransportConfig::GetValidationTags() "input.beamP", "input.beamStartZ", "output.path", + "output.overwrite", "target.material", "target.thickness", "target.diameter", @@ -35,7 +36,7 @@ CbmTransportConfig::TagSet_t CbmTransportConfig::GetValidationTags() "target.rotation.y", "beam.position.x", "beam.position.y", - "beam.position.z", + "beam.position.zFocus", "beam.position.sigmaX", "beam.position.sigmaY", "beam.angle.x", @@ -81,11 +82,13 @@ bool CbmTransportConfig::SetIO(CbmTransport& obj, const pt::ptree& moduleTree) auto inputs = moduleTree.get_child("input"); int inputCounter = 0; for (auto& input : inputs) { - pt::ptree pt_input = input.second; - string inputGenerator = pt_input.get<string>("generator", "unigen"); - string inputFile = GetStringValue(pt_input, "file", ""); + pt::ptree pt_input = input.second; - if (inputFile == "") { LOG(error) << "CbmTransportConfig: no input path specified for input #" << inputCounter; } + string inputGenerator = pt_input.get<string>("generator", ""); + if (inputGenerator == "") continue; // allow commenting out inputs + + string inputFile = GetStringValue(pt_input, "file", ""); + if (inputFile == "") { LOG(error) << "CbmTransportConfig: no path specified for input #" << inputCounter; } if (inputGenerator == "unigen") obj.AddInput(inputFile.c_str(), kUnigen); else if (inputGenerator == "pluto") { @@ -110,7 +113,14 @@ bool CbmTransportConfig::SetIO(CbmTransport& obj, const pt::ptree& moduleTree) if (confBeamQ) beamQ = confBeamQ.get(); else beamQ = confBeamA.get(); - if (confBeamStartZ) beamStartZ = confBeamStartZ.get(); + if (confBeamStartZ) { + beamStartZ = confBeamStartZ.get(); + if (targetZ && beamStartZ > targetZ.get()) { + LOG(error) << "CbmTransportConfig: beam starts after the target: \n target.position.z = " << targetZ.get() + << " cm\n beamStartZ = " << beamStartZ << " cm"; + return false; + } + } else if (targetZ) { beamStartZ = targetZ.get() - 1.; LOG(warning) << "CbmTransportConfig: beamStartZ=targetZ-1. cm"; @@ -139,9 +149,15 @@ bool CbmTransportConfig::SetIO(CbmTransport& obj, const pt::ptree& moduleTree) inputCounter++; } - string outputPath = GetStringValue(moduleTree, "output.path", "test"); + string outputPath = GetStringValue(moduleTree, "output.path", ""); + if (outputPath == "") { + LOG(error) << "CbmTransportConfig: No output path provided!"; + return false; + } LOG(info) << "CbmTransportConfig: Output path: " << outputPath; - obj.SetOutFileName(outputPath + ".tra.root"); + bool overwrite = moduleTree.get<bool>("output.overwrite", false); + if (overwrite) LOG(info) << "CbmTransportConfig: Overwrite output!"; + obj.SetOutFileName(outputPath + ".tra.root", overwrite); obj.SetParFileName(outputPath + ".par.root"); obj.SetGeoFileName(outputPath + ".geo.root"); @@ -181,7 +197,7 @@ bool CbmTransportConfig::SetBeamProfile(CbmTransport& obj, const pt::ptree& modu { auto posX = moduleTree.get_optional<float>("beam.position.x"); auto posY = moduleTree.get_optional<float>("beam.position.y"); - auto posZ = moduleTree.get_optional<float>("beam.position.z"); + auto posZ = moduleTree.get_optional<float>("beam.position.zFocus"); auto posSigmaX = moduleTree.get_optional<float>("beam.position.sigmaX"); auto posSigmaY = moduleTree.get_optional<float>("beam.position.sigmaY"); if (posX && posY) { @@ -219,7 +235,7 @@ bool CbmTransportConfig::SetBeamProfile(CbmTransport& obj, const pt::ptree& modu bool CbmTransportConfig::SetTransportParameters(CbmTransport& obj, const pt::ptree& moduleTree) { bool randomRP = true; - auto configRandomRP = moduleTree.get_optional<float>("randomRP"); + auto configRandomRP = moduleTree.get_optional<bool>("randomRP"); if (configRandomRP) randomRP = configRandomRP.get(); if (randomRP) obj.SetRandomEventPlane();