ATLAS Offline Software
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 
12 #include "AGDDModel/AGDDMolecule.h"
13 #include "AGDDModel/AGDDMixture.h"
14 #include <iostream>
15 
16 using namespace xercesc;
17 
20  : XMLHandler(s, c)
21 {
22 }
23 
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
AGDDMolecule
Definition: AGDDMolecule.h:16
python.CaloScaleNoiseConfig.parser
parser
Definition: CaloScaleNoiseConfig.py:75
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
compositeHandler::compositeHandler
compositeHandler(const std::string &, AGDDController &c)
Definition: compositeHandler.cxx:18
XercesParser.h
natomsHandler.h
AGDDMolecule.h
IAGDDParser
Definition: IAGDDParser.h:15
addmaterialHandler
Definition: addmaterialHandler.h:11
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
XMLHandler::getAttributeAsDouble
double getAttributeAsDouble(AGDDController &c, const xercesc::DOMNode *t, const std::string &) const
Definition: XMLHandler.cxx:78
AGDDController
Definition: AGDDController.h:30
compositeHandler::ElementHandle
virtual void ElementHandle(AGDDController &c, xercesc::DOMNode *t) override
Definition: compositeHandler.cxx:24
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.subdetectors.mmg.names
names
Definition: mmg.py:8
XMLHandlerStore.h
natomsHandler
Definition: natomsHandler.h:11
addmaterialHandler.h
natomsHandler::GetNatoms
std::vector< int > GetNatoms()
Definition: natomsHandler.cxx:23
addmaterialHandler::GetNames
std::vector< std::string > GetNames()
Definition: addmaterialHandler.cxx:27
XMLHandler::getAttributeAsString
std::string getAttributeAsString(AGDDController &c, const xercesc::DOMNode *t, const std::string &) const
Definition: XMLHandler.cxx:69
fractionmassHandler
Definition: fractionmassHandler.h:11
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AGDDMixture.h
XMLHandler
Definition: XMLHandler.h:15
AGDDMixture
Definition: AGDDMixture.h:16
fractionmassHandler::GetFractions
std::vector< double > GetFractions()
Definition: fractionmassHandler.cxx:22
fractionmassHandler.h
compositeHandler.h
python.compressB64.c
def c
Definition: compressB64.py:93
XMLHandler::StopLoop
void StopLoop(bool)
Definition: XMLHandler.cxx:28