31 #ifndef ROOT_TDOMParser
32 #include <TDOMParser.h>
39 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
47 #ifndef Gw_BaseNucleus
59 TMap *BaseNucleus::gTable =
new TMap();
62 BaseNucleus::BaseNucleus(): fA(0), fN(0), fZ(0)
80 if ( A < 0 || Z < 0 || A < Z )
return false;
90 if ( A < 0 || Z < 0 || N < 0 )
return false;
96 cout <<
" - ! - in BaseNucleus::Set N != A - Z " <<
endl;
104 if ((s == NULL) || A < 0)
return false;
106 if (gTable->GetSize() == 0) {
112 if ( (Z < 0) || (A-Z < 0) )
return false;
119 if (s == NULL)
return false;
121 if (gTable->GetSize() == 0) {
127 if ( Z < 0)
return false;
138 if (gTable->GetSize() == 0) {
143 TMapIter *iter = (TMapIter *)gTable->MakeIterator();
146 while ((str = (TNamed *)iter->Next())){
149 return str->GetName();
153 cout <<
" - ! - No Nucleus with Z = "<< Z <<
" found in the table - Please check Z" <<
endl;
158 if (gTable->GetSize() == 0) {
163 TMapIter *iter = (TMapIter *)gTable->MakeIterator();
166 while ((str = (TNamed *)iter->Next())){
169 return Form(
"%d%s", A, str->GetName() );
173 cout <<
" - ! - No Nucleus with Z = "<< Z <<
" found in the table - Please check Z" <<
endl;
179 if (s == NULL)
return -1;
180 if (gTable->GetSize() == 0) {
188 cout <<
" - !- No Nucleus named "<< s <<
" found in the table - Please check the symbol !!!" <<
endl;
196 if (s == NULL)
return "";
197 if (gTable->GetSize() == 0) {
202 TMapIter *iter = (TMapIter *)gTable->MakeIterator();
204 while ((str = (TNamed *)iter->Next())){
205 if (strcmp(str->GetName(), s) == 0) {
206 return str->GetTitle();
209 cout <<
" - ! - No Nucleus with symbol = "<< s<<
" found in the table - Please check the symbol" <<
endl;
214 if (gTable->GetSize() == 0) {
219 TMapIter *iter = (TMapIter *)gTable->MakeIterator();
222 while ((str = (TNamed *)iter->Next())){
225 return str->GetTitle();
229 cout <<
" - ! - No Nucleus with Z = "<< Z <<
" found in the table - Please check Z" <<
endl;
241 TString strxml = xmlfile;
242 if (strxml.IsNull()) {
243 strxml =
Gw::Env::GetPath(
"NdbPath");
if ( strxml.EndsWith(
"/") == kFALSE ) strxml +=
"/";
244 strxml +=
"TableNucleus.xml";
246 TDOMParser *domParser =
new TDOMParser();
247 Int_t parsecode = domParser->ParseFile(strxml.Data());
252 cout << domParser->GetParseCodeMessage(parsecode) <<
endl;
256 TXMLNode *node = domParser->GetXMLDocument()->GetRootNode();
258 TXMLNode *node2 = NULL;
259 TXMLNode *node3 = NULL;
264 TString sym,name,strtmp;
266 node = node->GetChildren();
269 for (; node; node = node->GetNextNode()) {
270 if (node->GetNodeType() == TXMLNode::kXMLElementNode) {
271 if (strcmp(node->GetNodeName(),
"nucleus") == 0) {
272 if (node->HasAttributes()) {
273 TList *attrList = node->GetAttributes();
275 TIter next(attrList);
276 while ((attr=(TXMLAttr*)next())) {
277 if (strcmp(attr->GetName(),
"symbol") == 0) {
278 sym = attr->GetValue();
280 if (strcmp(attr->GetName(),
"name") == 0) {
281 name = attr->GetValue();
284 str =
new TNamed(sym.Data(),name.Data());
287 node2 = node->GetChildren();
288 for ( ; node2; node2 = node2->GetNextNode()) {
289 if (node2->GetNodeType() == TXMLNode::kXMLElementNode) {
290 if (strcmp(node2->GetNodeName(),
"Z") == 0) {
291 node3 = node2->GetChildren();
292 strtmp = node3->GetContent();
293 bn =
new BaseNucleus( strtmp.Atoi(), strtmp.Atoi() , 0);
296 if (strcmp(node2->GetNodeName(),
"A") == 0) {
297 node3 = node2->GetChildren();
298 strtmp = node3->GetContent();
299 bn->
SetA(strtmp.Atoi());
302 if (strcmp(node2->GetNodeName(),
"N") == 0) {
303 node3 = node2->GetChildren();
304 strtmp = node3->GetContent();
305 bn->
SetN(strtmp.Atoi());
318 if (gTable->GetSize() != 0) {
323 TMapIter *iter = (TMapIter *)table.MakeIterator();
324 while ((str = (TNamed *)iter->Next())){
bool SetAZN(Int_t A, Int_t Z)
static const char * WhichFullName(const char *s)
return the full name corresponding to a symbol if it is found in the correspondence table...
BaseNucleus()
Set any components to 0.
static const char * WhichSymbol(Int_t Z)
return the symbol corresponding to Z if the nucleus is found in the correspondence table ...
static bool LoadTable(const char *xmlfile="")
Load the correspondence table between the symbol of the nucleus and Z from a XML file.
static Int_t WhichZ(const char *s)
return the number of protons (Z) corresponding to a symbol if the nucleus is found in the corresponde...
Base class for a nucleus which means its composition.
header file for a BaseNucleus
ADF::LogMessage & endl(ADF::LogMessage &log)
to get information about the gammaware configuration
static const char * GetPath(const char *)
to get a particular GW environment variable