Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AttCheck.cc File Reference
#include "G4AttCheck.hh"
#include "globals.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
#include "G4UIcommand.hh"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const G4AttCheck &ac)
 

Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const G4AttCheck ac 
)

Definition at line 245 of file G4AttCheck.cc.

246{
247 using namespace std;
248 if (ac.fpDefinitions == nullptr) {
249 os << "G4AttCheck: ERROR: zero definitions pointer." << endl;
250 return os;
251 }
252 G4String storeKey;
253 if (G4AttDefStore::GetStoreKey(ac.fpDefinitions, storeKey)) {
254 os << storeKey << ':' << endl;
255 }
256 if (ac.fpValues == nullptr) {
257 // A null values vector is a valid situation.
258 os << "G4AttCheck: zero values pointer." << endl;
259 return os;
260 }
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();
265 // NOLINTNEXTLINE(modernize-use-auto): Explicitly want a const_iterator
266 map<G4String,G4AttDef>::const_iterator iDef =
267 ac.fpDefinitions->find(valueName);
268 G4bool error = false;
269 if (iDef == ac.fpDefinitions->end()) {
270 error = true;
271 os << "G4AttCheck: ERROR: No G4AttDef for G4AttValue \""
272 << valueName << "\": " << value << endl;
273 } else {
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()) {
278 error = true;
279 os <<
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) {
285 os << ' ' << *i;
286 }
287 os << endl;
288 }
289 if(category == "Physics" && ac.fUnits->find(extra) == ac.fUnits->end()) {
290 error = true;
291 os <<
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) {
297 os << ' ' << *i;
298 }
299 os << endl;
300 }
301 if (ac.fValueTypes->find(valueType) == ac.fValueTypes->end()) {
302 error = true;
303 os <<
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) {
309 os << ' ' << *i;
310 }
311 os << endl;
312 }
313 }
314 if (!error) {
315 os << iDef->second.GetDesc()
316 << " (" << valueName
317 << "): " << value;
318 if (iDef->second.GetCategory() == "Physics" &&
319 !iDef->second.GetExtra().empty()) {
320 os << " (" << iDef->second.GetExtra() << ")";
321 }
322 os << endl;
323 }
324 }
325 return os;
326}
bool G4bool
Definition: G4Types.hh:86
G4bool GetStoreKey(const std::map< G4String, G4AttDef > *definitions, G4String &key)