Skip to content
Snippets Groups Projects
Commit 737b9324 authored by Joseph Boudreau's avatar Joseph Boudreau
Browse files

Merge branch 'debugOutputCNL' into 'master'

Add debug output for GeoModelXml copy number levels

See merge request !122
parents a7e1fce3 e032c5f5
No related branches found
No related tags found
1 merge request!122Add debug output for GeoModelXml copy number levels
...@@ -102,6 +102,8 @@ void GMXPlugin::create(GeoPhysVol *world, bool publish) ...@@ -102,6 +102,8 @@ void GMXPlugin::create(GeoPhysVol *world, bool publish)
std::cout<<"matman set to "<<matman<<std::endl; std::cout<<"matman set to "<<matman<<std::endl;
} }
char* levelmaps=getenv("GMX_DUMP_LEVEL_MAPS");
for (auto f: filesToParse) for (auto f: filesToParse)
{ {
if (!exists(f)) { if (!exists(f)) {
...@@ -110,7 +112,13 @@ void GMXPlugin::create(GeoPhysVol *world, bool publish) ...@@ -110,7 +112,13 @@ void GMXPlugin::create(GeoPhysVol *world, bool publish)
return; return;
} }
GmxInterface gmxInterface; GmxInterface gmxInterface;
Gmx2Geo gmx2Geo(f, world, gmxInterface, 0 , matman); if (levelmaps!=nullptr){
std::string mapname = f.substr(0, f.length() - 4);
mapname+="_levelMap.txt";
std::cout<<"Dumping Copy Number Level Map to "<<mapname<<std::endl;
Gmx2Geo gmx2Geo(f, world, gmxInterface, 0 , matman, mapname);
}
else Gmx2Geo gmx2Geo(f, world, gmxInterface, 0 , matman);
} }
if (matman) MaterialManager::getManager()->printAll(); if (matman) MaterialManager::getManager()->printAll();
......
...@@ -58,14 +58,14 @@ class IEvaluator; ...@@ -58,14 +58,14 @@ class IEvaluator;
class Gmx2Geo { class Gmx2Geo {
public: public:
Gmx2Geo(const std::string& gmxFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags = 0, bool useMatManager = 0,const processorList& procs=processorList()); Gmx2Geo(const std::string& gmxFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags = 0, bool useMatManager = 0, std::string levelMapName = "", const processorList& procs=processorList());
private: private:
// Disallow copying // Disallow copying
Gmx2Geo(const Gmx2Geo &right); Gmx2Geo(const Gmx2Geo &right);
Gmx2Geo & operator=(const Gmx2Geo &right); Gmx2Geo & operator=(const Gmx2Geo &right);
int doDefines(xercesc::DOMDocument *doc, GeoModelTools::IEvaluator &eval); int doDefines(xercesc::DOMDocument *doc, GeoModelTools::IEvaluator &eval);
int doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil); int doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil, std::string levelMapName = "");
int doReadoutGeometry(xercesc::DOMDocument *doc, GmxUtil &gmxUtil); int doReadoutGeometry(xercesc::DOMDocument *doc, GmxUtil &gmxUtil);
void addParam(xercesc::DOMNode *node, std::map<std::string, std::string> &params); void addParam(xercesc::DOMNode *node, std::map<std::string, std::string> &params);
}; };
......
...@@ -41,6 +41,11 @@ public: ...@@ -41,6 +41,11 @@ public:
void indices(std::map<std::string, int> &index, GeoModelTools::IEvaluator &eval); void indices(std::map<std::string, int> &index, GeoModelTools::IEvaluator &eval);
void addToLevelMap(std::string name, int level);
void printLevelMap();
void setLevelMapName(std::string filename);
std::string getLevelMapName();
private: private:
int m_level; int m_level;
std::vector <int> m_copyNo; // Size is always m_level+1 std::vector <int> m_copyNo; // Size is always m_level+1
...@@ -48,5 +53,7 @@ private: ...@@ -48,5 +53,7 @@ private:
*/ */
std::vector <std::string> m_name; std::vector <std::string> m_name;
std::map <std::string, std::string> m_formula; std::map <std::string, std::string> m_formula;
std::map <std::string, int> m_levelMap;
std::string m_mapName;
}; };
#endif // POSITIONINDEX_H #endif // POSITIONINDEX_H
...@@ -39,6 +39,7 @@ GeoNameTag *physVolName; ...@@ -39,6 +39,7 @@ GeoNameTag *physVolName;
XMLCh * name_tmp = XMLString::transcode("name"); XMLCh * name_tmp = XMLString::transcode("name");
char *name2release = XMLString::transcode(element->getAttribute(name_tmp)); char *name2release = XMLString::transcode(element->getAttribute(name_tmp));
string name(name2release); string name(name2release);
gmxUtil.positionIndex.addToLevelMap(name,gmxUtil.positionIndex.level());
XMLString::release(&name2release); XMLString::release(&name2release);
XMLString::release(&name_tmp); XMLString::release(&name_tmp);
// //
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
using namespace std; using namespace std;
using namespace xercesc; using namespace xercesc;
Gmx2Geo::Gmx2Geo(const string& xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags, bool useMatManager, const processorList& procs) { Gmx2Geo::Gmx2Geo(const string& xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags, bool useMatManager, std::string levelMapName, const processorList& procs) {
// //
// Create the xml tree (DOMDocument) // Create the xml tree (DOMDocument)
// //
...@@ -92,7 +92,7 @@ Gmx2Geo::Gmx2Geo(const string& xmlFile, GeoPhysVol *addHere, GmxInterface &gmxIn ...@@ -92,7 +92,7 @@ Gmx2Geo::Gmx2Geo(const string& xmlFile, GeoPhysVol *addHere, GmxInterface &gmxIn
// //
// Add all index names // Add all index names
// //
doPositionIndex(doc, gmxUtil); doPositionIndex(doc, gmxUtil, levelMapName);
// //
// The xml file ends with an addbranch element. We start there, process it, // The xml file ends with an addbranch element. We start there, process it,
// and it fills in the list of things to be added to the GeoModel graph. // and it fills in the list of things to be added to the GeoModel graph.
...@@ -262,7 +262,7 @@ const DOMElement *element; ...@@ -262,7 +262,7 @@ const DOMElement *element;
return 1; return 1;
} }
int Gmx2Geo::doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil) { int Gmx2Geo::doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil, std::string levelMapName) {
XMLCh * positionindex_tmp = XMLString::transcode("positionindex"); XMLCh * positionindex_tmp = XMLString::transcode("positionindex");
XMLCh * addindex_tmp = XMLString::transcode("addindex"); XMLCh * addindex_tmp = XMLString::transcode("addindex");
XMLCh * name_tmp = XMLString::transcode("name"); XMLCh * name_tmp = XMLString::transcode("name");
...@@ -277,6 +277,7 @@ int Gmx2Geo::doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil) { ...@@ -277,6 +277,7 @@ int Gmx2Geo::doPositionIndex(xercesc::DOMDocument *doc, GmxUtil &gmxUtil) {
DOMElement *addindex = dynamic_cast<DOMElement*>(addindexs->item(j)); DOMElement *addindex = dynamic_cast<DOMElement*>(addindexs->item(j));
string name = string(XMLString::transcode(addindex->getAttribute(name_tmp))); string name = string(XMLString::transcode(addindex->getAttribute(name_tmp)));
gmxUtil.positionIndex.addIndex(name); gmxUtil.positionIndex.addIndex(name);
if(levelMapName!="") gmxUtil.positionIndex.setLevelMapName(levelMapName);
} }
} }
XMLString::release(&positionindex_tmp); XMLString::release(&positionindex_tmp);
......
...@@ -41,6 +41,7 @@ void LogvolProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, GeoNo ...@@ -41,6 +41,7 @@ void LogvolProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, GeoNo
XMLCh * name_tmp = XMLString::transcode("name"); XMLCh * name_tmp = XMLString::transcode("name");
char *name2release = XMLString::transcode(element->getAttribute(name_tmp)); char *name2release = XMLString::transcode(element->getAttribute(name_tmp));
string name(name2release); string name(name2release);
gmxUtil.positionIndex.addToLevelMap(name,gmxUtil.positionIndex.level());
XMLString::release(&name2release); XMLString::release(&name2release);
XMLString::release(&name_tmp); XMLString::release(&name_tmp);
...@@ -229,6 +230,9 @@ void LogvolProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, GeoNo ...@@ -229,6 +230,9 @@ void LogvolProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, GeoNo
} }
gmxUtil.positionIndex.decrementLevel(); gmxUtil.positionIndex.decrementLevel();
if(gmxUtil.positionIndex.level()==-1){ //should mean that we are at the end of processing the geometry
gmxUtil.positionIndex.printLevelMap();
}
return; return;
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "OutputDirector.h" #include "OutputDirector.h"
#include <vector> #include <vector>
#include <string> #include <string>
#include <fstream>
#include "ExpressionEvaluator/IEvaluator.h" #include "ExpressionEvaluator/IEvaluator.h"
#include "GeoModelXml/PositionIndex.h" #include "GeoModelXml/PositionIndex.h"
...@@ -13,6 +14,8 @@ using namespace std; ...@@ -13,6 +14,8 @@ using namespace std;
PositionIndex::PositionIndex() { PositionIndex::PositionIndex() {
m_level = -1; // Level -1 represents the "world" with no Copy Number m_level = -1; // Level -1 represents the "world" with no Copy Number
m_levelMap.clear();
m_mapName = "";
} }
PositionIndex::~PositionIndex() {} PositionIndex::~PositionIndex() {}
...@@ -112,3 +115,31 @@ void PositionIndex::indices(map<string, int> &index, GeoModelTools::IEvaluator & ...@@ -112,3 +115,31 @@ void PositionIndex::indices(map<string, int> &index, GeoModelTools::IEvaluator &
eval.setVariable(name.c_str(), (double) index[name]); eval.setVariable(name.c_str(), (double) index[name]);
} }
} }
void PositionIndex::addToLevelMap(std::string name,int level){
m_levelMap[name]=level;
}
void PositionIndex::setLevelMapName(std::string name){
m_mapName = name;
}
std::string PositionIndex::getLevelMapName(){
return m_mapName;
}
void PositionIndex::printLevelMap(){
if(m_mapName!=""){
std::ofstream outfile(m_mapName);
outfile<<"----------CNL Map----------\n\n";
for (auto const& entry: m_levelMap){
outfile<<"Item: "<<entry.first<<" Level: CNL_"<<entry.second<<" last copyNumber at Level:"<<m_copyNo[entry.second]<<"\n";
}
outfile<<"\n\n";
outfile.close();
}
//otherwise, do nothing
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment