ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
AGDD
AGDDHandlers
src
compositeHandler.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AGDDHandlers/compositeHandler.h
"
6
#include "
AGDDHandlers/addmaterialHandler.h
"
7
#include "
AGDDHandlers/natomsHandler.h
"
8
#include "
AGDDHandlers/fractionmassHandler.h
"
9
#include "
AGDDControl/XercesParser.h
"
10
#include "
AGDDControl/XMLHandlerStore.h
"
11
#include "
AGDDControl/AGDDController.h
"
12
#include "
AGDDModel/AGDDMolecule.h
"
13
#include "
AGDDModel/AGDDMixture.h
"
14
#include <iostream>
15
16
using namespace
xercesc;
17
18
compositeHandler::compositeHandler
(
const
std::string& s,
19
AGDDController
& c)
20
:
XMLHandler
(s, c)
21
{
22
}
23
24
void
compositeHandler::ElementHandle
(
AGDDController
& c,
25
xercesc::DOMNode *t)
26
{
27
std::string name=
getAttributeAsString
(c, t,
"name"
);
28
double
density=
getAttributeAsDouble
(c, t,
"density"
);
29
StopLoop
(
true
);
30
31
addmaterialHandler
* addmatHand =
dynamic_cast<
addmaterialHandler
*
>
32
(c.GetHandlerStore().GetHandler(
"addmaterial"
));
33
if
(!addmatHand) std::abort();
34
35
natomsHandler
* natomsHand =
dynamic_cast<
natomsHandler
*
>
36
(c.GetHandlerStore().GetHandler(
"natoms"
));
37
if
(!natomsHand) std::abort();
38
39
fractionmassHandler
* fractionsHand =
dynamic_cast<
fractionmassHandler
*
>
40
(c.GetHandlerStore().GetHandler(
"fractionmass"
));
41
if
(!fractionsHand) std::abort();
42
43
addmatHand->
GetNames
();
44
natomsHand->
GetNatoms
();
45
fractionsHand->
GetFractions
();
46
47
DOMNode* child;
48
49
IAGDDParser
& parser = *c.GetParser();
50
for
(child=t->getFirstChild();child!=0;child=child->getNextSibling())
51
{
52
if
(child->getNodeType()==DOMNode::ELEMENT_NODE) {
53
parser.elementLoop(c, child);
54
}
55
}
56
57
std::vector<std::string> names = addmatHand->
GetNames
();
58
std::vector<int> natoms = natomsHand->
GetNatoms
();
59
std::vector<double> fractions = fractionsHand->
GetFractions
();
60
61
if
(!natoms.empty())
62
{
63
// it's a molecule
64
AGDDMolecule
*m=
new
AGDDMolecule
(c.GetMaterialStore(),name,density);
65
for
(
unsigned
int
i=0;i<natoms.size();i++)
66
{
67
m->AddElement(c.GetMaterialStore(), names[i]);
68
m->NAtoms(natoms[i]);
69
}
70
}
71
else
if
(!fractions.empty())
72
{
73
// it's a mixture
74
AGDDMixture
*m=
new
AGDDMixture
(c.GetMaterialStore(),name,density);
75
for
(
unsigned
int
i=0;i<fractions.size();i++)
76
{
77
m->AddMaterial(c.GetMaterialStore(), names[i]);
78
m->Fraction(fractions[i]);
79
}
80
}
81
else
82
std::cout<<
"Something wrong: "
<<name<<
" neither molecule nor mixture!!!"
<<std::endl;
83
}
AGDDController.h
AGDDMixture.h
AGDDMolecule.h
XMLHandlerStore.h
XercesParser.h
addmaterialHandler.h
AGDDController
Definition
AGDDController.h:30
AGDDMixture
Definition
AGDDMixture.h:16
AGDDMolecule
Definition
AGDDMolecule.h:16
IAGDDParser
Definition
IAGDDParser.h:15
XMLHandler::StopLoop
void StopLoop(bool)
Definition
XMLHandler.cxx:28
XMLHandler::getAttributeAsDouble
double getAttributeAsDouble(AGDDController &c, const xercesc::DOMNode *t, const std::string &) const
Definition
XMLHandler.cxx:78
XMLHandler::XMLHandler
XMLHandler(const std::string &n, AGDDController &c)
Definition
XMLHandler.cxx:15
XMLHandler::getAttributeAsString
std::string getAttributeAsString(AGDDController &c, const xercesc::DOMNode *t, const std::string &) const
Definition
XMLHandler.cxx:69
addmaterialHandler
Definition
addmaterialHandler.h:12
addmaterialHandler::GetNames
std::vector< std::string > GetNames()
Definition
addmaterialHandler.cxx:20
compositeHandler::ElementHandle
virtual void ElementHandle(AGDDController &c, xercesc::DOMNode *t) override
Definition
compositeHandler.cxx:24
compositeHandler::compositeHandler
compositeHandler(const std::string &, AGDDController &c)
Definition
compositeHandler.cxx:18
fractionmassHandler
Definition
fractionmassHandler.h:11
fractionmassHandler::GetFractions
std::vector< double > GetFractions()
Definition
fractionmassHandler.cxx:22
natomsHandler
Definition
natomsHandler.h:11
natomsHandler::GetNatoms
std::vector< int > GetNatoms()
Definition
natomsHandler.cxx:23
compositeHandler.h
fractionmassHandler.h
natomsHandler.h
Generated on
for ATLAS Offline Software by
1.17.0