51(
const std::vector<G4AttValue>* values,
52 const std::map<G4String,G4AttDef>* definitions):
54 fpDefinitions(definitions)
62 fUnitCategories->insert(
"Length");
63 fUnitCategories->insert(
"Energy");
64 fUnitCategories->insert(
"Time");
65 fUnitCategories->insert(
"Electric charge");
66 fUnitCategories->insert(
"Volumic Mass");
69 (*fStandardUnits)[
"Length"] =
"m";
70 (*fStandardUnits)[
"Energy"] =
"MeV";
71 (*fStandardUnits)[
"Time"] =
"ns";
72 (*fStandardUnits)[
"Electric charge"] =
"e+";
73 (*fStandardUnits)[
"Volumic Mass"] =
"kg/m3";
76 fCategories->insert(
"Bookkeeping");
77 fCategories->insert(
"Draw");
78 fCategories->insert(
"Physics");
79 fCategories->insert(
"PickAction");
80 fCategories->insert(
"Association");
84 fUnits->insert(
"G4BestUnit");
87 for (
size_t i = 0; i < units.size(); ++i) {
88 if (fUnitCategories->find(units[i]->GetName()) !=
89 fUnitCategories->end()) {
92 for (
auto & j : container) {
95 fUnits->insert(j->GetSymbol());
101 fValueTypes->insert(
"G4String");
102 fValueTypes->insert(
"G4int");
103 fValueTypes->insert(
"G4double");
104 fValueTypes->insert(
"G4ThreeVector");
105 fValueTypes->insert(
"G4bool");
124 if (iError < 10 || iError%100 == 0) {
128 if (fpValues ==
nullptr)
return error;
129 if (fpDefinitions ==
nullptr) {
134 "\n*******************************************************";
135 if (!leader.empty()) {
139 "\nG4AttCheck: ERROR " << iError <<
": Null definitions pointer"
140 "\n*******************************************************"
145 vector<G4AttValue>::const_iterator iValue;
146 for (iValue = fpValues->begin(); iValue != fpValues->end(); ++iValue) {
147 const G4String& valueName = iValue->GetName();
148 const G4String& value = iValue->GetValue();
150 map<G4String,G4AttDef>::const_iterator iDef =
151 fpDefinitions->find(valueName);
152 if (iDef == fpDefinitions->end()) {
157 "\n*******************************************************";
158 if (!leader.empty()) {
162 "\nG4AttCheck: ERROR " << iError <<
": No G4AttDef for G4AttValue \""
163 << valueName <<
"\": " << value <<
164 "\n*******************************************************"
168 const G4String& category = iDef->second.GetCategory();
169 const G4String& extra = iDef->second.GetExtra();
170 const G4String& valueType = iDef->second.GetValueType();
171 if (fCategories->find(category) == fCategories->end()) {
176 "\n*******************************************************";
177 if (!leader.empty()) {
181 "\nG4AttCheck: ERROR " << iError <<
": Illegal Category Field \""
182 << category <<
"\" for G4AttValue \""
183 << valueName <<
"\": " << value <<
184 "\n Possible Categories:";
185 set<G4String>::iterator i;
186 for (i = fCategories->begin(); i != fCategories->end(); ++i) {
190 "\n*******************************************************"
194 if(category ==
"Physics" && fUnits->find(extra) == fUnits->end()) {
199 "\n*******************************************************";
200 if (!leader.empty()) {
204 "\nG4AttCheck: ERROR " << iError <<
": Illegal Extra field \""
205 << extra <<
"\" for G4AttValue \""
206 << valueName <<
"\": " << value <<
207 "\n Possible Extra fields if Category==\"Physics\":\n ";
208 set<G4String>::iterator i;
209 for (i = fUnits->begin(); i != fUnits->end(); ++i) {
213 "\n*******************************************************"
217 if (fValueTypes->find(valueType) == fValueTypes->end()) {
222 "\n*******************************************************";
223 if (!leader.empty()) {
227 "\nG4AttCheck: ERROR " << iError <<
": Illegal Value Type field \""
228 << valueType <<
"\" for G4AttValue \""
229 << valueName <<
"\": " << value <<
230 "\n Possible Value Types:";
231 set<G4String>::iterator i;
232 for (i = fValueTypes->begin(); i != fValueTypes->end(); ++i) {
236 "\n*******************************************************"
248 if (ac.fpDefinitions ==
nullptr) {
249 os <<
"G4AttCheck: ERROR: zero definitions pointer." << endl;
254 os << storeKey <<
':' << endl;
256 if (ac.fpValues ==
nullptr) {
258 os <<
"G4AttCheck: zero values pointer." << endl;
261 vector<G4AttValue>::const_iterator iValue;
262 for (iValue = ac.fpValues->begin(); iValue != ac.fpValues->end(); ++iValue) {
263 const G4String& valueName = iValue->GetName();
264 const G4String& value = iValue->GetValue();
266 map<G4String,G4AttDef>::const_iterator iDef =
267 ac.fpDefinitions->find(valueName);
269 if (iDef == ac.fpDefinitions->end()) {
271 os <<
"G4AttCheck: ERROR: No G4AttDef for G4AttValue \""
272 << valueName <<
"\": " << value << endl;
274 const G4String& category = iDef->second.GetCategory();
275 const G4String& extra = iDef->second.GetExtra();
276 const G4String& valueType = iDef->second.GetValueType();
277 if (ac.fCategories->find(category) == ac.fCategories->end()) {
280 "G4AttCheck: ERROR: Illegal Category Field \"" << category
281 <<
"\" for G4AttValue \"" << valueName <<
"\": " << value <<
282 "\n Possible Categories:";
283 set<G4String>::iterator i;
284 for (i = ac.fCategories->begin(); i != ac.fCategories->end(); ++i) {
289 if(category ==
"Physics" && ac.fUnits->find(extra) == ac.fUnits->end()) {
292 "G4AttCheck: ERROR: Illegal Extra field \""<< extra
293 <<
"\" for G4AttValue \"" << valueName <<
"\": " << value <<
294 "\n Possible Extra fields if Category==\"Physics\":\n ";
295 set<G4String>::iterator i;
296 for (i = ac.fUnits->begin(); i != ac.fUnits->end(); ++i) {
301 if (ac.fValueTypes->find(valueType) == ac.fValueTypes->end()) {
304 "G4AttCheck: ERROR: Illegal Value Type field \"" << valueType
305 <<
"\" for G4AttValue \"" << valueName <<
"\": " << value <<
306 "\n Possible Value Types:";
307 set<G4String>::iterator i;
308 for (i = ac.fValueTypes->begin(); i != ac.fValueTypes->end(); ++i) {
315 os << iDef->second.GetDesc()
318 if (iDef->second.GetCategory() ==
"Physics" &&
319 !iDef->second.GetExtra().empty()) {
320 os <<
" (" << iDef->second.GetExtra() <<
")";
348(std::vector<G4AttValue>* standardValues,
349 std::map<G4String,G4AttDef>* standardDefinitions)
const
355 vector<G4AttValue>::const_iterator iValue;
356 for (iValue = fpValues->begin(); iValue != fpValues->end(); ++iValue) {
357 const G4String& valueName = iValue->GetName();
358 const G4String& value = iValue->GetValue();
360 map<G4String,G4AttDef>::const_iterator iDef =
361 fpDefinitions->find(valueName);
362 if (iDef == fpDefinitions->end()) {
365 const G4String& category = iDef->second.GetCategory();
366 const G4String& extra = iDef->second.GetExtra();
367 const G4String& valueType = iDef->second.GetValueType();
368 if (fCategories->find(category) == fCategories->end() ||
369 (category ==
"Physics" && fUnits->find(extra) == fUnits->end()) ||
370 fValueTypes->find(valueType) == fValueTypes->end()) {
373 if (category !=
"Physics") {
374 standardValues->push_back(*iValue);
375 (*standardDefinitions)[valueName] =
376 fpDefinitions->find(valueName)->second;
379 if (valueType ==
"G4ThreeVector") {
383 (standardValues,standardDefinitions,
384 valueName,valueName+
"-X",
386 fpDefinitions->find(valueName)->second.GetDesc()+
"-X");
388 (standardValues,standardDefinitions,
389 valueName,valueName+
"-Y",
391 fpDefinitions->find(valueName)->second.GetDesc()+
"-Y");
393 (standardValues,standardDefinitions,
394 valueName,valueName+
"-Z",
396 fpDefinitions->find(valueName)->second.GetDesc()+
"-Z");
398 standardValues->push_back(*iValue);
399 (*standardDefinitions)[valueName] =
400 fpDefinitions->find(valueName)->second;
405 if (extra ==
"G4BestUnit") {
406 valueAndUnit = G4StrUtil::strip_copy(value);
407 unit = valueAndUnit.substr(valueAndUnit.rfind(
' ')+1);
409 valueAndUnit = G4StrUtil::strip_copy(value +
' ' + extra);
413 if (fUnitCategories->find(unitCategory) != fUnitCategories->end()) {
414 G4String standardUnit = (*fStandardUnits)[unitCategory];
418 if (valueType ==
"G4ThreeVector") {
422 (standardValues,standardDefinitions,
423 valueName,valueName+
"-X",
425 (internalValue.
x()/valueOfStandardUnit),
427 fpDefinitions->find(valueName)->second.GetDesc()+
"-X");
429 (standardValues,standardDefinitions,
430 valueName,valueName+
"-Y",
432 (internalValue.
y()/valueOfStandardUnit),
434 fpDefinitions->find(valueName)->second.GetDesc()+
"-Y");
436 (standardValues,standardDefinitions,
437 valueName,valueName+
"-Z",
439 (internalValue.
z()/valueOfStandardUnit),
441 fpDefinitions->find(valueName)->second.GetDesc()+
"-Z");
446 (standardValues,standardDefinitions,
449 (internalValue/valueOfStandardUnit),
459 G4cerr <<
"G4AttCheck::Standard: Conversion error." <<
G4endl;