52 (
const std::vector<G4AttValue>* values,
53 const std::map<G4String,G4AttDef>* definitions):
55 fpDefinitions(definitions)
63 fUnitCategories->insert(
"Length");
64 fUnitCategories->insert(
"Energy");
65 fUnitCategories->insert(
"Time");
66 fUnitCategories->insert(
"Electric charge");
67 fUnitCategories->insert(
"Volumic Mass");
70 (*fStandardUnits)[
"Length"] =
"m";
71 (*fStandardUnits)[
"Energy"] =
"MeV";
72 (*fStandardUnits)[
"Time"] =
"ns";
73 (*fStandardUnits)[
"Electric charge"] =
"e+";
74 (*fStandardUnits)[
"Volumic Mass"] =
"kg/m3";
77 fCategories->insert(
"Bookkeeping");
78 fCategories->insert(
"Draw");
79 fCategories->insert(
"Physics");
80 fCategories->insert(
"PickAction");
81 fCategories->insert(
"Association");
85 fUnits->insert(
"G4BestUnit");
88 for (
size_t i = 0; i < units.size(); ++i) {
89 if (fUnitCategories->find(units[i]->GetName()) !=
90 fUnitCategories->end()) {
93 for (
size_t j = 0; j < container.size(); ++j) {
96 fUnits->insert(container[j]->GetSymbol());
102 fValueTypes->insert(
"G4String");
103 fValueTypes->insert(
"G4int");
104 fValueTypes->insert(
"G4double");
105 fValueTypes->insert(
"G4ThreeVector");
106 fValueTypes->insert(
"G4bool");
129 if (iError < 10 || iError%100 == 0) {
139 "\n*******************************************************";
144 "\nG4AttCheck: ERROR " << iError <<
": Null definitions pointer"
145 "\n*******************************************************"
150 vector<G4AttValue>::const_iterator iValue;
152 const G4String& valueName = iValue->GetName();
154 map<G4String,G4AttDef>::const_iterator iDef =
161 "\n*******************************************************";
166 "\nG4AttCheck: ERROR " << iError <<
": No G4AttDef for G4AttValue \""
167 << valueName <<
"\": " << value <<
168 "\n*******************************************************"
172 const G4String& category = iDef->second.GetCategory();
173 const G4String& extra = iDef->second.GetExtra();
174 const G4String& valueType = iDef->second.GetValueType();
180 "\n*******************************************************";
185 "\nG4AttCheck: ERROR " << iError <<
": Illegal Category Field \""
186 << category <<
"\" for G4AttValue \""
187 << valueName <<
"\": " << value <<
188 "\n Possible Categories:";
189 set<G4String>::iterator i;
194 "\n*******************************************************"
198 if(category ==
"Physics" &&
fUnits->find(extra) ==
fUnits->end()) {
203 "\n*******************************************************";
208 "\nG4AttCheck: ERROR " << iError <<
": Illegal Extra field \""
209 << extra <<
"\" for G4AttValue \""
210 << valueName <<
"\": " << value <<
211 "\n Possible Extra fields if Category==\"Physics\":\n ";
212 set<G4String>::iterator i;
217 "\n*******************************************************"
226 "\n*******************************************************";
231 "\nG4AttCheck: ERROR " << iError <<
": Illegal Value Type field \""
232 << valueType <<
"\" for G4AttValue \""
233 << valueName <<
"\": " << value <<
234 "\n Possible Value Types:";
235 set<G4String>::iterator i;
240 "\n*******************************************************"
253 os <<
"G4AttCheck: ERROR: zero definitions pointer." << endl;
258 os << storeKey <<
':' << endl;
262 os <<
"G4AttCheck: zero values pointer." << endl;
265 vector<G4AttValue>::const_iterator iValue;
266 for (iValue = ac.
fpValues->begin(); iValue != ac.
fpValues->end(); ++iValue) {
267 const G4String& valueName = iValue->GetName();
269 map<G4String,G4AttDef>::const_iterator iDef =
274 os <<
"G4AttCheck: ERROR: No G4AttDef for G4AttValue \""
275 << valueName <<
"\": " << value << endl;
277 const G4String& category = iDef->second.GetCategory();
278 const G4String& extra = iDef->second.GetExtra();
279 const G4String& valueType = iDef->second.GetValueType();
283 "G4AttCheck: ERROR: Illegal Category Field \"" << category
284 <<
"\" for G4AttValue \"" << valueName <<
"\": " << value <<
285 "\n Possible Categories:";
286 set<G4String>::iterator i;
292 if(category ==
"Physics" && ac.
fUnits->find(extra) == ac.
fUnits->end()) {
295 "G4AttCheck: ERROR: Illegal Extra field \""<< extra
296 <<
"\" for G4AttValue \"" << valueName <<
"\": " << value <<
297 "\n Possible Extra fields if Category==\"Physics\":\n ";
298 set<G4String>::iterator i;
299 for (i = ac.
fUnits->begin(); i != ac.
fUnits->end(); ++i) {
307 "G4AttCheck: ERROR: Illegal Value Type field \"" << valueType
308 <<
"\" for G4AttValue \"" << valueName <<
"\": " << value <<
309 "\n Possible Value Types:";
310 set<G4String>::iterator i;
318 os << iDef->second.GetDesc()
321 if (iDef->second.GetCategory() ==
"Physics" &&
322 !iDef->second.GetExtra().empty()) {
323 os <<
" (" << iDef->second.GetExtra() <<
")";
332 (std::vector<G4AttValue>* standardValues,
333 std::map<G4String,G4AttDef>* standardDefinitions,
341 standardValues->push_back(
G4AttValue(name,value,
""));
345 (*standardDefinitions)[
name].SetName(name);
346 (*standardDefinitions)[
name].SetExtra(extra);
347 if (description !=
"") (*standardDefinitions)[
name].SetDesc(description);
351 (std::vector<G4AttValue>* standardValues,
352 std::map<G4String,G4AttDef>* standardDefinitions)
const
358 vector<G4AttValue>::const_iterator iValue;
360 const G4String& valueName = iValue->GetName();
361 const G4String& value = iValue->GetValue();
362 map<G4String,G4AttDef>::const_iterator iDef =
367 const G4String& category = iDef->second.GetCategory();
368 const G4String& extra = iDef->second.GetExtra();
369 const G4String& valueType = iDef->second.GetValueType();
371 (category ==
"Physics" &&
fUnits->find(extra) ==
fUnits->end()) ||
375 if (category !=
"Physics") {
376 standardValues->push_back(*iValue);
377 (*standardDefinitions)[valueName] =
381 if (valueType ==
"G4ThreeVector") {
385 (standardValues,standardDefinitions,
386 valueName,valueName+
"-X",
390 (standardValues,standardDefinitions,
391 valueName,valueName+
"-Y",
395 (standardValues,standardDefinitions,
396 valueName,valueName+
"-Z",
400 standardValues->push_back(*iValue);
401 (*standardDefinitions)[valueName] =
407 if (extra ==
"G4BestUnit") {
408 valueAndUnit =
value;
409 valueAndUnit = valueAndUnit.
strip();
410 unit = valueAndUnit.substr(valueAndUnit.rfind(
' ')+1);
412 valueAndUnit = value +
' ' + extra;
413 valueAndUnit = valueAndUnit.
strip();
418 G4String standardUnit = (*fStandardUnits)[unitCategory];
422 if (valueType ==
"G4ThreeVector") {
426 (standardValues,standardDefinitions,
427 valueName,valueName+
"-X",
429 (internalValue.
x()/valueOfStandardUnit),
433 (standardValues,standardDefinitions,
434 valueName,valueName+
"-Y",
436 (internalValue.
y()/valueOfStandardUnit),
440 (standardValues,standardDefinitions,
441 valueName,valueName+
"-Z",
443 (internalValue.
z()/valueOfStandardUnit),
450 (standardValues,standardDefinitions,
453 (internalValue/valueOfStandardUnit),
463 G4cerr <<
"G4AttCheck::Standard: Conversion error." <<
G4endl;
void print(G4double elem)
static G4ThreadLocal std::set< G4String > * fUnitCategories
static G4ThreadLocal std::set< G4String > * fCategories
std::vector< G4UnitsCategory * > G4UnitsTable
static G4ThreadLocal std::set< G4String > * fUnits
const XML_Char int const XML_Char * value
G4bool Standard(std::vector< G4AttValue > *standardValues, std::map< G4String, G4AttDef > *standardDefinitions) const
G4String strip(G4int strip_Type=trailing, char c=' ')
static G4double GetValueOf(const G4String &)
static G4UnitsTable & GetUnitsTable()
static G4ThreeVector ConvertTo3Vector(const char *st)
G4GLOB_DLL std::ostream G4cerr
static G4String ConvertToString(G4bool boolVal)
static G4ThreadLocal G4bool fFirst
std::vector< G4UnitDefinition * > G4UnitsContainer
G4bool Check(const G4String &leader="") const
const std::vector< G4AttValue > * fpValues
static G4ThreadLocal std::map< G4String, G4String > * fStandardUnits
static PROLOG_HANDLER error
static G4String GetCategory(const G4String &)
G4AttCheck(const std::vector< G4AttValue > *values, const std::map< G4String, G4AttDef > *definitions)
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
static G4ThreadLocal std::set< G4String > * fValueTypes
static G4double ConvertToDimensionedDouble(const char *st)
void AddValuesAndDefs(std::vector< G4AttValue > *newValues, std::map< G4String, G4AttDef > *newDefinitions, const G4String &oldName, const G4String &name, const G4String &value, const G4String &extra, const G4String &description="") const
friend std::ostream & operator<<(std::ostream &, const G4AttCheck &)
G4bool GetStoreKey(const std::map< G4String, G4AttDef > *definitions, G4String &key)
const std::map< G4String, G4AttDef > * fpDefinitions