Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 27 28 #include "G4AttCheck.hh" 28 #include "G4AttCheck.hh" 29 29 30 #include "globals.hh" 30 #include "globals.hh" 31 31 32 #include "G4AttDef.hh" 32 #include "G4AttDef.hh" 33 #include "G4AttDefStore.hh" 33 #include "G4AttDefStore.hh" 34 #include "G4AttValue.hh" 34 #include "G4AttValue.hh" 35 #include "G4UnitsTable.hh" 35 #include "G4UnitsTable.hh" 36 #include "G4UIcommand.hh" 36 #include "G4UIcommand.hh" 37 37 38 G4ThreadLocal G4bool G4AttCheck::fFirst = true 38 G4ThreadLocal G4bool G4AttCheck::fFirst = true; 39 39 40 G4ThreadLocal std::set<G4String> *G4AttCheck:: << 40 G4ThreadLocal std::set<G4String> *G4AttCheck::fUnitCategories = 0; 41 41 42 G4ThreadLocal std::map<G4String,G4String> *G4A << 42 G4ThreadLocal std::map<G4String,G4String> *G4AttCheck::fStandardUnits = 0; 43 43 44 G4ThreadLocal std::set<G4String> *G4AttCheck:: << 44 G4ThreadLocal std::set<G4String> *G4AttCheck::fCategories = 0; 45 45 46 G4ThreadLocal std::set<G4String> *G4AttCheck:: << 46 G4ThreadLocal std::set<G4String> *G4AttCheck::fUnits = 0; 47 47 48 G4ThreadLocal std::set<G4String> *G4AttCheck:: << 48 G4ThreadLocal std::set<G4String> *G4AttCheck::fValueTypes = 0; 49 49 50 G4AttCheck::G4AttCheck 50 G4AttCheck::G4AttCheck 51 (const std::vector<G4AttValue>* values, 51 (const std::vector<G4AttValue>* values, 52 const std::map<G4String,G4AttDef>* definition 52 const std::map<G4String,G4AttDef>* definitions): 53 fpValues(values), 53 fpValues(values), 54 fpDefinitions(definitions) 54 fpDefinitions(definitions) 55 { 55 { 56 Init(); 56 Init(); 57 57 58 if (fFirst) { // Initialise static containe 58 if (fFirst) { // Initialise static containers. 59 fFirst = false; 59 fFirst = false; 60 60 61 // Legal Unit Category Types... 61 // Legal Unit Category Types... 62 fUnitCategories->insert("Length"); 62 fUnitCategories->insert("Length"); 63 fUnitCategories->insert("Energy"); 63 fUnitCategories->insert("Energy"); 64 fUnitCategories->insert("Time"); 64 fUnitCategories->insert("Time"); 65 fUnitCategories->insert("Electric charge") 65 fUnitCategories->insert("Electric charge"); 66 fUnitCategories->insert("Volumic Mass"); 66 fUnitCategories->insert("Volumic Mass"); // (Density) 67 67 68 // Corresponding Standard Units... 68 // Corresponding Standard Units... 69 (*fStandardUnits)["Length"] = "m"; 69 (*fStandardUnits)["Length"] = "m"; 70 (*fStandardUnits)["Energy"] = "MeV"; 70 (*fStandardUnits)["Energy"] = "MeV"; 71 (*fStandardUnits)["Time"] = "ns"; 71 (*fStandardUnits)["Time"] = "ns"; 72 (*fStandardUnits)["Electric charge"] = "e+ 72 (*fStandardUnits)["Electric charge"] = "e+"; 73 (*fStandardUnits)["Volumic Mass"] = "kg/m3 73 (*fStandardUnits)["Volumic Mass"] = "kg/m3"; 74 74 75 // Legal Categories... 75 // Legal Categories... 76 fCategories->insert("Bookkeeping"); 76 fCategories->insert("Bookkeeping"); 77 fCategories->insert("Draw"); 77 fCategories->insert("Draw"); 78 fCategories->insert("Physics"); 78 fCategories->insert("Physics"); 79 fCategories->insert("PickAction"); 79 fCategories->insert("PickAction"); 80 fCategories->insert("Association"); 80 fCategories->insert("Association"); 81 81 82 // Legal units... 82 // Legal units... 83 fUnits->insert(""); 83 fUnits->insert(""); 84 fUnits->insert("G4BestUnit"); 84 fUnits->insert("G4BestUnit"); 85 // ...plus any legal unit symbol ("MeV", " 85 // ...plus any legal unit symbol ("MeV", "km", etc.)... 86 G4UnitsTable& units = G4UnitDefinition::Ge 86 G4UnitsTable& units = G4UnitDefinition::GetUnitsTable(); 87 for (size_t i = 0; i < units.size(); ++i) 87 for (size_t i = 0; i < units.size(); ++i) { 88 if (fUnitCategories->find(units[i]->GetN 88 if (fUnitCategories->find(units[i]->GetName()) != 89 fUnitCategories->end()) { 89 fUnitCategories->end()) { 90 //G4cout << units[i]->GetName() << G4e 90 //G4cout << units[i]->GetName() << G4endl; 91 G4UnitsContainer& container = units[i] 91 G4UnitsContainer& container = units[i]->GetUnitsList(); 92 for (auto & j : container) { << 92 for (size_t j = 0; j < container.size(); ++j) { 93 //G4cout << container[j]->GetName() 93 //G4cout << container[j]->GetName() << ' ' 94 // << container[j]->GetSymbol( 94 // << container[j]->GetSymbol() << G4endl; 95 fUnits->insert(j->GetSymbol()); << 95 fUnits->insert(container[j]->GetSymbol()); 96 } 96 } 97 } 97 } 98 } 98 } 99 99 100 // Legal Value Types... 100 // Legal Value Types... 101 fValueTypes->insert("G4String"); 101 fValueTypes->insert("G4String"); 102 fValueTypes->insert("G4int"); 102 fValueTypes->insert("G4int"); 103 fValueTypes->insert("G4double"); 103 fValueTypes->insert("G4double"); 104 fValueTypes->insert("G4ThreeVector"); 104 fValueTypes->insert("G4ThreeVector"); 105 fValueTypes->insert("G4bool"); 105 fValueTypes->insert("G4bool"); 106 } 106 } 107 } 107 } 108 108 >> 109 G4AttCheck::~G4AttCheck() >> 110 { >> 111 } >> 112 109 void G4AttCheck::Init() 113 void G4AttCheck::Init() 110 { 114 { 111 if (fValueTypes == nullptr) fValueTypes = ne << 115 if (!fValueTypes) fValueTypes = new std::set<G4String>; 112 if (fUnits == nullptr) fUnits = new std::set << 116 if (!fUnits) fUnits = new std::set<G4String>; 113 if (fCategories == nullptr) fCategories = ne << 117 if (!fCategories) fCategories = new std::set<G4String>; 114 if (fStandardUnits == nullptr) fStandardUnit << 118 if (!fStandardUnits) fStandardUnits = new std::map<G4String,G4String>; 115 if (fUnitCategories == nullptr) fUnitCategor << 119 if (!fUnitCategories) fUnitCategories = new std::set<G4String>; 116 } 120 } 117 121 118 G4bool G4AttCheck::Check(const G4String& leade 122 G4bool G4AttCheck::Check(const G4String& leader) const 119 { 123 { 120 // Check only. Silent unless error - then G 124 // Check only. Silent unless error - then G4cerr. Returns error. 121 G4bool error = false; 125 G4bool error = false; 122 static G4ThreadLocal G4int iError = 0; 126 static G4ThreadLocal G4int iError = 0; 123 G4bool print = false; 127 G4bool print = false; 124 if (iError < 10 || iError%100 == 0) { 128 if (iError < 10 || iError%100 == 0) { 125 print = true; 129 print = true; 126 } 130 } 127 using namespace std; 131 using namespace std; 128 if (fpValues == nullptr) return error; // A << 132 if (!fpValues) return error; // A null values vector is a valid situation. 129 if (fpDefinitions == nullptr) { << 133 if (!fpDefinitions) { 130 ++iError; 134 ++iError; 131 error = true; 135 error = true; 132 if (print) { 136 if (print) { 133 G4cerr << 137 G4cerr << 134 "\n*********************************** 138 "\n*******************************************************"; 135 if (!leader.empty()) { << 139 if (leader != "") { 136 G4cerr << '\n' << leader; 140 G4cerr << '\n' << leader; 137 } 141 } 138 G4cerr << 142 G4cerr << 139 "\nG4AttCheck: ERROR " << iError << ": 143 "\nG4AttCheck: ERROR " << iError << ": Null definitions pointer" 140 "\n*********************************** 144 "\n*******************************************************" 141 << G4endl; 145 << G4endl; 142 } 146 } 143 return error; 147 return error; 144 } 148 } 145 vector<G4AttValue>::const_iterator iValue; 149 vector<G4AttValue>::const_iterator iValue; 146 for (iValue = fpValues->begin(); iValue != f 150 for (iValue = fpValues->begin(); iValue != fpValues->end(); ++iValue) { 147 const G4String& valueName = iValue->GetNam 151 const G4String& valueName = iValue->GetName(); 148 const G4String& value = iValue->GetValue() 152 const G4String& value = iValue->GetValue(); 149 // NOLINTNEXTLINE(modernize-use-auto): Exp << 150 map<G4String,G4AttDef>::const_iterator iDe 153 map<G4String,G4AttDef>::const_iterator iDef = 151 fpDefinitions->find(valueName); 154 fpDefinitions->find(valueName); 152 if (iDef == fpDefinitions->end()) { 155 if (iDef == fpDefinitions->end()) { 153 ++iError; 156 ++iError; 154 error = true; 157 error = true; 155 if (print) { 158 if (print) { 156 G4cerr << 159 G4cerr << 157 "\n********************************* 160 "\n*******************************************************"; 158 if (!leader.empty()) { << 161 if (leader != "") { 159 G4cerr << '\n' << leader; 162 G4cerr << '\n' << leader; 160 } 163 } 161 G4cerr << 164 G4cerr << 162 "\nG4AttCheck: ERROR " << iError << 165 "\nG4AttCheck: ERROR " << iError << ": No G4AttDef for G4AttValue \"" 163 << valueName << "\": " << valu 166 << valueName << "\": " << value << 164 "\n********************************* 167 "\n*******************************************************" 165 << G4endl; 168 << G4endl; 166 } 169 } 167 } else { 170 } else { 168 const G4String& category = iDef->second. 171 const G4String& category = iDef->second.GetCategory(); 169 const G4String& extra = iDef->second.Get 172 const G4String& extra = iDef->second.GetExtra(); 170 const G4String& valueType = iDef->second 173 const G4String& valueType = iDef->second.GetValueType(); 171 if (fCategories->find(category) == fCate 174 if (fCategories->find(category) == fCategories->end()) { 172 ++iError; 175 ++iError; 173 error = true; 176 error = true; 174 if (print) { 177 if (print) { 175 G4cerr << 178 G4cerr << 176 "\n******************************* 179 "\n*******************************************************"; 177 if (!leader.empty()) { << 180 if (leader != "") { 178 G4cerr << '\n' << leader; 181 G4cerr << '\n' << leader; 179 } 182 } 180 G4cerr << 183 G4cerr << 181 "\nG4AttCheck: ERROR " << iError < 184 "\nG4AttCheck: ERROR " << iError << ": Illegal Category Field \"" 182 << category << "\" for G4AttV 185 << category << "\" for G4AttValue \"" 183 << valueName << "\": " << val 186 << valueName << "\": " << value << 184 "\n Possible Categories:"; 187 "\n Possible Categories:"; 185 set<G4String>::iterator i; 188 set<G4String>::iterator i; 186 for (i = fCategories->begin(); i != 189 for (i = fCategories->begin(); i != fCategories->end(); ++i) { 187 G4cerr << ' ' << *i; 190 G4cerr << ' ' << *i; 188 } 191 } 189 G4cerr << 192 G4cerr << 190 "\n******************************* 193 "\n*******************************************************" 191 << G4endl; 194 << G4endl; 192 } 195 } 193 } 196 } 194 if(category == "Physics" && fUnits->find 197 if(category == "Physics" && fUnits->find(extra) == fUnits->end()) { 195 ++iError; 198 ++iError; 196 error = true; 199 error = true; 197 if (print) { 200 if (print) { 198 G4cerr << 201 G4cerr << 199 "\n******************************* 202 "\n*******************************************************"; 200 if (!leader.empty()) { << 203 if (leader != "") { 201 G4cerr << '\n' << leader; 204 G4cerr << '\n' << leader; 202 } 205 } 203 G4cerr << 206 G4cerr << 204 "\nG4AttCheck: ERROR " << iError < 207 "\nG4AttCheck: ERROR " << iError << ": Illegal Extra field \"" 205 << extra << "\" for G4AttValu 208 << extra << "\" for G4AttValue \"" 206 << valueName << "\": " << val 209 << valueName << "\": " << value << 207 "\n Possible Extra fields if Cate 210 "\n Possible Extra fields if Category==\"Physics\":\n "; 208 set<G4String>::iterator i; 211 set<G4String>::iterator i; 209 for (i = fUnits->begin(); i != fUnit 212 for (i = fUnits->begin(); i != fUnits->end(); ++i) { 210 G4cerr << ' ' << *i; 213 G4cerr << ' ' << *i; 211 } 214 } 212 G4cerr << 215 G4cerr << 213 "\n******************************* 216 "\n*******************************************************" 214 << G4endl; 217 << G4endl; 215 } 218 } 216 } 219 } 217 if (fValueTypes->find(valueType) == fVal 220 if (fValueTypes->find(valueType) == fValueTypes->end()) { 218 ++iError; 221 ++iError; 219 error = true; 222 error = true; 220 if (print) { 223 if (print) { 221 G4cerr << 224 G4cerr << 222 "\n******************************* 225 "\n*******************************************************"; 223 if (!leader.empty()) { << 226 if (leader != "") { 224 G4cerr << '\n' << leader; 227 G4cerr << '\n' << leader; 225 } 228 } 226 G4cerr << 229 G4cerr << 227 "\nG4AttCheck: ERROR " << iError < 230 "\nG4AttCheck: ERROR " << iError << ": Illegal Value Type field \"" 228 << valueType << "\" for G4Att 231 << valueType << "\" for G4AttValue \"" 229 << valueName << "\": " << val 232 << valueName << "\": " << value << 230 "\n Possible Value Types:"; 233 "\n Possible Value Types:"; 231 set<G4String>::iterator i; 234 set<G4String>::iterator i; 232 for (i = fValueTypes->begin(); i != 235 for (i = fValueTypes->begin(); i != fValueTypes->end(); ++i) { 233 G4cerr << ' ' << *i; 236 G4cerr << ' ' << *i; 234 } 237 } 235 G4cerr << 238 G4cerr << 236 "\n******************************* 239 "\n*******************************************************" 237 << G4endl; 240 << G4endl; 238 } 241 } 239 } 242 } 240 } 243 } 241 } 244 } 242 return error; 245 return error; 243 } 246 } 244 247 245 std::ostream& operator<< (std::ostream& os, co 248 std::ostream& operator<< (std::ostream& os, const G4AttCheck& ac) 246 { 249 { 247 using namespace std; 250 using namespace std; 248 if (ac.fpDefinitions == nullptr) { << 251 if (!ac.fpDefinitions) { 249 os << "G4AttCheck: ERROR: zero definitions 252 os << "G4AttCheck: ERROR: zero definitions pointer." << endl; 250 return os; 253 return os; 251 } 254 } 252 G4String storeKey; 255 G4String storeKey; 253 if (G4AttDefStore::GetStoreKey(ac.fpDefiniti 256 if (G4AttDefStore::GetStoreKey(ac.fpDefinitions, storeKey)) { 254 os << storeKey << ':' << endl; 257 os << storeKey << ':' << endl; 255 } 258 } 256 if (ac.fpValues == nullptr) { << 259 if (!ac.fpValues) { 257 // A null values vector is a valid situati 260 // A null values vector is a valid situation. 258 os << "G4AttCheck: zero values pointer." < 261 os << "G4AttCheck: zero values pointer." << endl; 259 return os; 262 return os; 260 } 263 } 261 vector<G4AttValue>::const_iterator iValue; 264 vector<G4AttValue>::const_iterator iValue; 262 for (iValue = ac.fpValues->begin(); iValue ! 265 for (iValue = ac.fpValues->begin(); iValue != ac.fpValues->end(); ++iValue) { 263 const G4String& valueName = iValue->GetNam 266 const G4String& valueName = iValue->GetName(); 264 const G4String& value = iValue->GetValue() 267 const G4String& value = iValue->GetValue(); 265 // NOLINTNEXTLINE(modernize-use-auto): Exp << 268 map<G4String,G4AttDef>::const_iterator iDef = 266 map<G4String,G4AttDef>::const_iterator iDe << 267 ac.fpDefinitions->find(valueName); 269 ac.fpDefinitions->find(valueName); 268 G4bool error = false; 270 G4bool error = false; 269 if (iDef == ac.fpDefinitions->end()) { 271 if (iDef == ac.fpDefinitions->end()) { 270 error = true; 272 error = true; 271 os << "G4AttCheck: ERROR: No G4AttDef fo 273 os << "G4AttCheck: ERROR: No G4AttDef for G4AttValue \"" 272 << valueName << "\": " << value << en 274 << valueName << "\": " << value << endl; 273 } else { 275 } else { 274 const G4String& category = iDef->second. 276 const G4String& category = iDef->second.GetCategory(); 275 const G4String& extra = iDef->second.Get 277 const G4String& extra = iDef->second.GetExtra(); 276 const G4String& valueType = iDef->second 278 const G4String& valueType = iDef->second.GetValueType(); 277 if (ac.fCategories->find(category) == ac 279 if (ac.fCategories->find(category) == ac.fCategories->end()) { 278 error = true; 280 error = true; 279 os << 281 os << 280 "G4AttCheck: ERROR: Illegal Category 282 "G4AttCheck: ERROR: Illegal Category Field \"" << category 281 << "\" for G4AttValue \"" << valueN 283 << "\" for G4AttValue \"" << valueName << "\": " << value << 282 "\n Possible Categories:"; 284 "\n Possible Categories:"; 283 set<G4String>::iterator i; 285 set<G4String>::iterator i; 284 for (i = ac.fCategories->begin(); i != 286 for (i = ac.fCategories->begin(); i != ac.fCategories->end(); ++i) { 285 os << ' ' << *i; 287 os << ' ' << *i; 286 } 288 } 287 os << endl; 289 os << endl; 288 } 290 } 289 if(category == "Physics" && ac.fUnits->f 291 if(category == "Physics" && ac.fUnits->find(extra) == ac.fUnits->end()) { 290 error = true; 292 error = true; 291 os << 293 os << 292 "G4AttCheck: ERROR: Illegal Extra fi 294 "G4AttCheck: ERROR: Illegal Extra field \""<< extra 293 << "\" for G4AttValue \"" << valueN 295 << "\" for G4AttValue \"" << valueName << "\": " << value << 294 "\n Possible Extra fields if Catego 296 "\n Possible Extra fields if Category==\"Physics\":\n "; 295 set<G4String>::iterator i; 297 set<G4String>::iterator i; 296 for (i = ac.fUnits->begin(); i != ac.f 298 for (i = ac.fUnits->begin(); i != ac.fUnits->end(); ++i) { 297 os << ' ' << *i; 299 os << ' ' << *i; 298 } 300 } 299 os << endl; 301 os << endl; 300 } 302 } 301 if (ac.fValueTypes->find(valueType) == a 303 if (ac.fValueTypes->find(valueType) == ac.fValueTypes->end()) { 302 error = true; 304 error = true; 303 os << 305 os << 304 "G4AttCheck: ERROR: Illegal Value Ty 306 "G4AttCheck: ERROR: Illegal Value Type field \"" << valueType 305 << "\" for G4AttValue \"" << valueN 307 << "\" for G4AttValue \"" << valueName << "\": " << value << 306 "\n Possible Value Types:"; 308 "\n Possible Value Types:"; 307 set<G4String>::iterator i; 309 set<G4String>::iterator i; 308 for (i = ac.fValueTypes->begin(); i != 310 for (i = ac.fValueTypes->begin(); i != ac.fValueTypes->end(); ++i) { 309 os << ' ' << *i; 311 os << ' ' << *i; 310 } 312 } 311 os << endl; 313 os << endl; 312 } 314 } 313 } 315 } 314 if (!error) { 316 if (!error) { 315 os << iDef->second.GetDesc() 317 os << iDef->second.GetDesc() 316 << " (" << valueName 318 << " (" << valueName 317 << "): " << value; 319 << "): " << value; 318 if (iDef->second.GetCategory() == "Physi 320 if (iDef->second.GetCategory() == "Physics" && 319 !iDef->second.GetExtra().empty()) { 321 !iDef->second.GetExtra().empty()) { 320 os << " (" << iDef->second.GetExtra() 322 os << " (" << iDef->second.GetExtra() << ")"; 321 } 323 } 322 os << endl; 324 os << endl; 323 } 325 } 324 } 326 } 325 return os; 327 return os; 326 } 328 } 327 329 328 void G4AttCheck::AddValuesAndDefs 330 void G4AttCheck::AddValuesAndDefs 329 (std::vector<G4AttValue>* standardValues, 331 (std::vector<G4AttValue>* standardValues, 330 std::map<G4String,G4AttDef>* standardDefiniti 332 std::map<G4String,G4AttDef>* standardDefinitions, 331 const G4String& oldName, 333 const G4String& oldName, 332 const G4String& name, 334 const G4String& name, 333 const G4String& value, 335 const G4String& value, 334 const G4String& extra, 336 const G4String& extra, 335 const G4String& description) const 337 const G4String& description) const 336 { 338 { 337 // Add new G4AttDeff... 339 // Add new G4AttDeff... 338 standardValues->push_back(G4AttValue(name,va 340 standardValues->push_back(G4AttValue(name,value,"")); 339 // Copy original G4AttDef... 341 // Copy original G4AttDef... 340 (*standardDefinitions)[name] = fpDefinitions 342 (*standardDefinitions)[name] = fpDefinitions->find(oldName)->second; 341 // ...and make appropriate changes... 343 // ...and make appropriate changes... 342 (*standardDefinitions)[name].SetName(name); 344 (*standardDefinitions)[name].SetName(name); 343 (*standardDefinitions)[name].SetExtra(extra) 345 (*standardDefinitions)[name].SetExtra(extra); 344 if (!description.empty()) (*standardDefiniti << 346 if (description != "") (*standardDefinitions)[name].SetDesc(description); 345 } 347 } 346 348 347 G4bool G4AttCheck::Standard 349 G4bool G4AttCheck::Standard 348 (std::vector<G4AttValue>* standardValues, 350 (std::vector<G4AttValue>* standardValues, 349 std::map<G4String,G4AttDef>* standardDefiniti 351 std::map<G4String,G4AttDef>* standardDefinitions) const 350 { 352 { 351 // Places standard versions in provided vect 353 // Places standard versions in provided vector and map and returns error. 352 // Assumes valid input. Use Check to check. 354 // Assumes valid input. Use Check to check. 353 using namespace std; 355 using namespace std; 354 G4bool error = false; 356 G4bool error = false; 355 vector<G4AttValue>::const_iterator iValue; 357 vector<G4AttValue>::const_iterator iValue; 356 for (iValue = fpValues->begin(); iValue != f 358 for (iValue = fpValues->begin(); iValue != fpValues->end(); ++iValue) { 357 const G4String& valueName = iValue->GetNam 359 const G4String& valueName = iValue->GetName(); 358 const G4String& value = iValue->GetValue() 360 const G4String& value = iValue->GetValue(); 359 // NOLINTNEXTLINE(modernize-use-auto): Exp << 360 map<G4String,G4AttDef>::const_iterator iDe 361 map<G4String,G4AttDef>::const_iterator iDef = 361 fpDefinitions->find(valueName); 362 fpDefinitions->find(valueName); 362 if (iDef == fpDefinitions->end()) { 363 if (iDef == fpDefinitions->end()) { 363 error = true; 364 error = true; 364 } else { 365 } else { 365 const G4String& category = iDef->second. 366 const G4String& category = iDef->second.GetCategory(); 366 const G4String& extra = iDef->second.Get 367 const G4String& extra = iDef->second.GetExtra(); 367 const G4String& valueType = iDef->second 368 const G4String& valueType = iDef->second.GetValueType(); 368 if (fCategories->find(category) == fCate 369 if (fCategories->find(category) == fCategories->end() || 369 (category == "Physics" && fUnits->fi 370 (category == "Physics" && fUnits->find(extra) == fUnits->end()) || 370 fValueTypes->find(valueType) == fVal 371 fValueTypes->find(valueType) == fValueTypes->end()) { 371 error = true; 372 error = true; 372 } else { 373 } else { 373 if (category != "Physics") { // Simpl 374 if (category != "Physics") { // Simply copy... 374 standardValues->push_back(*iValue); 375 standardValues->push_back(*iValue); 375 (*standardDefinitions)[valueName] = 376 (*standardDefinitions)[valueName] = 376 fpDefinitions->find(valueName)->se 377 fpDefinitions->find(valueName)->second; 377 } else { // "Physics"... 378 } else { // "Physics"... 378 if (extra.empty()) { // Dimensionle 379 if (extra.empty()) { // Dimensionless... 379 if (valueType == "G4ThreeVector") 380 if (valueType == "G4ThreeVector") { // Split vector into 3... 380 G4ThreeVector internalValue = 381 G4ThreeVector internalValue = 381 G4UIcommand::ConvertTo3Vector( 382 G4UIcommand::ConvertTo3Vector(value); 382 AddValuesAndDefs 383 AddValuesAndDefs 383 (standardValues,standardDefini 384 (standardValues,standardDefinitions, 384 valueName,valueName+"-X", 385 valueName,valueName+"-X", 385 G4UIcommand::ConvertToString( 386 G4UIcommand::ConvertToString(internalValue.x()),"", 386 fpDefinitions->find(valueName 387 fpDefinitions->find(valueName)->second.GetDesc()+"-X"); 387 AddValuesAndDefs 388 AddValuesAndDefs 388 (standardValues,standardDefini 389 (standardValues,standardDefinitions, 389 valueName,valueName+"-Y", 390 valueName,valueName+"-Y", 390 G4UIcommand::ConvertToString( 391 G4UIcommand::ConvertToString(internalValue.y()),"", 391 fpDefinitions->find(valueName 392 fpDefinitions->find(valueName)->second.GetDesc()+"-Y"); 392 AddValuesAndDefs 393 AddValuesAndDefs 393 (standardValues,standardDefini 394 (standardValues,standardDefinitions, 394 valueName,valueName+"-Z", 395 valueName,valueName+"-Z", 395 G4UIcommand::ConvertToString( 396 G4UIcommand::ConvertToString(internalValue.z()),"", 396 fpDefinitions->find(valueName 397 fpDefinitions->find(valueName)->second.GetDesc()+"-Z"); 397 } else { // Simply copy... 398 } else { // Simply copy... 398 standardValues->push_back(*iValu 399 standardValues->push_back(*iValue); 399 (*standardDefinitions)[valueName 400 (*standardDefinitions)[valueName] = 400 fpDefinitions->find(valueName) 401 fpDefinitions->find(valueName)->second; 401 } 402 } 402 } else { // Dimensioned... 403 } else { // Dimensioned... 403 G4String valueAndUnit; 404 G4String valueAndUnit; 404 G4String unit; 405 G4String unit; 405 if (extra == "G4BestUnit") { 406 if (extra == "G4BestUnit") { 406 valueAndUnit = G4StrUtil::strip_ << 407 valueAndUnit = value; >> 408 valueAndUnit = valueAndUnit.strip(); 407 unit = valueAndUnit.substr(value 409 unit = valueAndUnit.substr(valueAndUnit.rfind(' ')+1); 408 } else { 410 } else { 409 valueAndUnit = G4StrUtil::strip_ << 411 valueAndUnit = value + ' ' + extra; >> 412 valueAndUnit = valueAndUnit.strip(); 410 unit = extra; 413 unit = extra; 411 } 414 } 412 G4String unitCategory = G4UnitDefi 415 G4String unitCategory = G4UnitDefinition::GetCategory(unit); 413 if (fUnitCategories->find(unitCate 416 if (fUnitCategories->find(unitCategory) != fUnitCategories->end()) { 414 G4String standardUnit = (*fStand 417 G4String standardUnit = (*fStandardUnits)[unitCategory]; 415 G4double valueOfStandardUnit = 418 G4double valueOfStandardUnit = 416 G4UnitDefinition::GetValueOf(s 419 G4UnitDefinition::GetValueOf(standardUnit); 417 // G4String exstr = iDef->second. 420 // G4String exstr = iDef->second.GetExtra(); 418 if (valueType == "G4ThreeVector" 421 if (valueType == "G4ThreeVector") { // Split vector into 3... 419 G4ThreeVector internalValue = 422 G4ThreeVector internalValue = 420 G4UIcommand::ConvertToDimens 423 G4UIcommand::ConvertToDimensioned3Vector(valueAndUnit); 421 AddValuesAndDefs 424 AddValuesAndDefs 422 (standardValues,standardDefi 425 (standardValues,standardDefinitions, 423 valueName,valueName+"-X", 426 valueName,valueName+"-X", 424 G4UIcommand::ConvertToStrin 427 G4UIcommand::ConvertToString 425 (internalValue.x()/valueOfS 428 (internalValue.x()/valueOfStandardUnit), 426 standardUnit, 429 standardUnit, 427 fpDefinitions->find(valueNa 430 fpDefinitions->find(valueName)->second.GetDesc()+"-X"); 428 AddValuesAndDefs 431 AddValuesAndDefs 429 (standardValues,standardDefi 432 (standardValues,standardDefinitions, 430 valueName,valueName+"-Y", 433 valueName,valueName+"-Y", 431 G4UIcommand::ConvertToStrin 434 G4UIcommand::ConvertToString 432 (internalValue.y()/valueOfS 435 (internalValue.y()/valueOfStandardUnit), 433 standardUnit, 436 standardUnit, 434 fpDefinitions->find(valueNa 437 fpDefinitions->find(valueName)->second.GetDesc()+"-Y"); 435 AddValuesAndDefs 438 AddValuesAndDefs 436 (standardValues,standardDefi 439 (standardValues,standardDefinitions, 437 valueName,valueName+"-Z", 440 valueName,valueName+"-Z", 438 G4UIcommand::ConvertToStrin 441 G4UIcommand::ConvertToString 439 (internalValue.z()/valueOfS 442 (internalValue.z()/valueOfStandardUnit), 440 standardUnit, 443 standardUnit, 441 fpDefinitions->find(valueNa 444 fpDefinitions->find(valueName)->second.GetDesc()+"-Z"); 442 } else { 445 } else { 443 G4double internalValue = 446 G4double internalValue = 444 G4UIcommand::ConvertToDimens 447 G4UIcommand::ConvertToDimensionedDouble(valueAndUnit); 445 AddValuesAndDefs 448 AddValuesAndDefs 446 (standardValues,standardDefi 449 (standardValues,standardDefinitions, 447 valueName,valueName, 450 valueName,valueName, 448 G4UIcommand::ConvertToStrin 451 G4UIcommand::ConvertToString 449 (internalValue/valueOfStand 452 (internalValue/valueOfStandardUnit), 450 standardUnit); 453 standardUnit); 451 } 454 } 452 } 455 } 453 } 456 } 454 } 457 } 455 } 458 } 456 } 459 } 457 } 460 } 458 if (error) { 461 if (error) { 459 G4cerr << "G4AttCheck::Standard: Conversio 462 G4cerr << "G4AttCheck::Standard: Conversion error." << G4endl; 460 } 463 } 461 return error; 464 return error; 462 } 465 } 463 466