38 : fNumPrecision(numPrecision),
39 fAngleUnit(angleUnit),
40 fLengthUnit(lengthUnit),
69 std::cerr <<
" XmlVGM::Maps::Maps:" << std::endl;
70 std::cerr <<
" Dummy constructor protected." << std::endl;
71 std::cerr <<
"** Exception: Aborting execution **" << std::endl;
87 std::cerr <<
" XmlVGM::Maps::Maps:" << std::endl;
88 std::cerr <<
" Copy constructor not implemented." << std::endl;
89 std::cerr <<
"** Exception: Aborting execution **" << std::endl;
109 if (
this == &right)
return *
this;
111 std::cerr <<
" XmlVGM::Maps::operator=:" << std::endl;
112 std::cerr <<
" Assignement operator not implemented." << std::endl;
113 std::cerr <<
"** Exception: Aborting execution **" << std::endl;
124void XmlVGM::Maps::CutName(std::string& name)
const
128 int i = name.length();
129 while (name[--i] ==
' ') name = std::string(name, 0, i);
133double XmlVGM::Maps::Round2(
double number)
const
137 double precision = fNumPrecision;
138 return ClhepVGM::Round(number * pow(10., precision)) / pow(10., precision);
148 double roundedPI = Round2(
M_PI / fAngleUnit);
151 roundedRotation[0] = Round2(rotation[0] / fAngleUnit);
152 roundedRotation[1] = Round2(rotation[1] / fAngleUnit);
153 roundedRotation[2] = Round2(rotation[2] / fAngleUnit);
156 rotation2[0] = rotation[0];
157 rotation2[1] = rotation[1];
158 rotation2[2] = rotation[2];
160 if (roundedRotation[0] == -roundedPI) rotation2[0] = -rotation2[0];
161 if (roundedRotation[1] == -roundedPI) rotation2[1] = -rotation2[1];
162 if (roundedRotation[2] == -roundedPI) rotation2[2] = -rotation2[2];
183 roundedPosition[0] = Round2(position[0] / fLengthUnit);
184 roundedPosition[1] = Round2(position[1] / fLengthUnit);
185 roundedPosition[2] = Round2(position[2] / fLengthUnit);
187 if (fPositions.find(roundedPosition) != fPositions.end())
return "";
191 std::string name(
"pos_");
192 std::ostringstream tmpStream;
193 tmpStream << fPositions.size();
194 name.append(tmpStream.str());
197 fPositions[roundedPosition] = name;
216 roundedRotation[0] = Round2(rotation2[0] / fAngleUnit);
217 roundedRotation[1] = Round2(rotation2[1] / fAngleUnit);
218 roundedRotation[2] = Round2(rotation2[2] / fAngleUnit);
220 if (fRotations.find(roundedRotation) != fRotations.end())
return "";
224 std::string name(
"rot_");
225 std::ostringstream tmpStream;
226 tmpStream << fRotations.size();
227 name.append(tmpStream.str());
230 fRotations[roundedRotation] = name;
240 std::string name(
"posB_");
241 std::ostringstream tmpStream;
242 tmpStream << fNofBoolPositions++;
243 name.append(tmpStream.str());
253 std::string name(
"rotB_");
254 std::ostringstream tmpStream;
255 tmpStream << fNofBoolRotations++;
256 name.append(tmpStream.str());
269 roundedValues[0] = Round2(isotope->
Z());
270 roundedValues[1] = Round2(isotope->
N());
271 roundedValues[2] = Round2(isotope->
A());
274 IsotopeMap::iterator it;
275 for (it = fIsotopes.begin(); it != fIsotopes.end(); it++) {
276 if ((*it).first == roundedValues && (*it).second->Name() == isotope->
Name())
282 fIsotopes.insert(std::make_pair(roundedValues, isotope));
295 roundedValues[0] = Round2(element->
Z());
296 roundedValues[1] = Round2(element->
N());
297 roundedValues[2] = Round2(element->
A());
300 ElementMap::iterator it;
301 for (it = fElements.begin(); it != fElements.end(); it++) {
302 if ((*it).first == roundedValues && (*it).second->Name() == element->
Name())
308 fElements.insert(std::make_pair(roundedValues, element));
319 std::string name = material->
Name();
322 if (fMaterials.find(name) != fMaterials.end())
return 0;
325 fMaterials[name] = material;
336 std::string name = medium->
Name();
339 if (fMedia.find(name) != fMedia.end())
return 0;
342 fMedia[name] = medium;
361 roundedPosition[0] = Round2(position[0] / fLengthUnit);
362 roundedPosition[1] = Round2(position[1] / fLengthUnit);
363 roundedPosition[2] = Round2(position[2] / fLengthUnit);
365 ThreeVectorMap::const_iterator it = fPositions.find(roundedPosition);
366 if (it != fPositions.end())
369 return std::string();
389 roundedRotation[0] = Round2(rotation2[0] / fAngleUnit);
390 roundedRotation[1] = Round2(rotation2[1] / fAngleUnit);
391 roundedRotation[2] = Round2(rotation2[2] / fAngleUnit);
393 ThreeVectorMap::const_iterator it = fRotations.find(roundedRotation);
394 if (it != fRotations.end())
397 return std::string();
405 ThreeVectorMap::const_iterator it1;
406 for (it1 = fPositions.begin(); it1 != fPositions.end(); it1++)
415 ThreeVectorMap::const_iterator it1;
416 for (it1 = fRotations.begin(); it1 != fRotations.end(); it1++)
425 IsotopeMap::const_iterator it1;
426 for (it1 = fIsotopes.begin(); it1 != fIsotopes.end(); it1++)
435 ElementMap::const_iterator it1;
436 for (it1 = fElements.begin(); it1 != fElements.end(); it1++)
445 MaterialMap::const_iterator it2;
446 for (it2 = fMaterials.begin(); it2 != fMaterials.end(); it2++)
455 MediumMap::const_iterator it;
456 for (it = fMedia.begin(); it != fMedia.end(); it++)
465 MaterialMap::const_iterator it;
466 for (it = fMaterials.begin(); it != fMaterials.end(); it++)
475 fPositions.erase(fPositions.begin(), fPositions.end());
476 fRotations.erase(fRotations.begin(), fRotations.end());
477 fIsotopes.erase(fIsotopes.begin(), fIsotopes.end());
478 fElements.erase(fElements.begin(), fElements.end());
479 fMaterials.erase(fMaterials.begin(), fMaterials.end());
480 fMedia.erase(fMedia.begin(), fMedia.end());
The VGM interface to elements.
virtual double Z() const =0
Return the effective atomic number.
virtual std::string Name() const =0
Return the name of this element.
virtual double A() const =0
Return the effective effective mass of a mole in g/mole.
virtual double N() const =0
Return the effective number of nucleons.
The VGM interface to elements.
virtual int N() const =0
Return the effective number of nucleons.
virtual std::string Name() const =0
Return the name of this element.
virtual double A() const =0
Return the effective effective mass of a mole in g/mole.
virtual int Z() const =0
Return the effective atomic number.
The VGM interface to materials.
virtual std::string Name() const =0
Return the name of this element.
The VGM interface to tracking medium.
virtual std::string Name() const =0
Return its name.
The interface for the XML writer that writes VGM geometry objects to XML:
virtual void WriteIsotope(const VGM::IIsotope *isotope)=0
Write VGM isotope.
virtual void WriteElement(const VGM::IElement *element)=0
Write VGM element.
virtual void WritePosition(const std::string &name, const VGM::Transform &position)=0
Write position (from VGM transformation)
virtual void WriteRotation(const std::string &name, const VGM::Transform &rotation)=0
Write rotation (from VGM transformation)
virtual void WriteMaterial(const VGM::IMaterial *material)=0
Write VGM material.
virtual void WriteMedium(const VGM::IMedium *medium)=0
Write VGM medium.
Utility class for mapping XML element values to their names within the XML exporter precision.
const VGM::IElement * AddElement(const VGM::IElement *element)
void WriteAllRotations(IWriter *writer)
std::string AddBooleanPosition()
const VGM::IMaterial * AddMaterial(const VGM::IMaterial *material)
void WriteAllPositions(IWriter *writer)
std::string FindPositionName(const VGM::Transform &transform) const
void WriteAllMedia(IWriter *writer)
Maps & operator=(const Maps &)
void WriteAllMediaFromMaterials(IWriter *writer)
std::string FindRotationName(const VGM::Transform &transform) const
std::string AddPosition(const VGM::Transform &transform)
const VGM::IIsotope * AddIsotope(const VGM::IIsotope *isotope)
std::string AddRotation(const VGM::Transform &transform)
void WriteAllIsotopes(IWriter *writer)
std::string AddBooleanRotation()
const VGM::IMedium * AddMedium(const VGM::IMedium *medium)
void WriteAllMaterials(IWriter *writer)
void WriteAllElements(IWriter *writer)
#define M_PI
Definition of math constant M_PI not available on Win32.
std::vector< double > Transform
std::vector< double > ThreeVector
void CutName(std::string &name)