83 using namespace HEPREP;
84 using namespace cheprep;
87 G4int G4HepRepSceneHandler::sceneIdCount = 0;
95 geometryLayer (
"Geometry"),
97 calHitLayer (
"CalHit"),
98 trajectoryLayer (
"Trajectory"),
100 rootVolumeName (
"Geometry"),
102 eventNumberPrefix (
""),
103 eventNumberSuffix (
""),
105 eventNumberWidth (-1),
110 writeMultipleFiles (false),
114 _heprepGeometry (NULL)
118 cout <<
"G4HepRepSceneHandler::G4HepRepSceneHandler: " << system << endl;
136 cout <<
"G4HepRepSceneHandler::~G4HepRepSceneHandler() " << endl;
148 if (writer != NULL)
return;
150 if (name ==
"stdout") {
152 cout <<
"G4HepRepSceneHandler::Open() stdout" << endl;
157 eventNumberPrefix =
"";
158 eventNumberSuffix =
"";
163 writeMultipleFiles =
false;
165 eventNumberWidth = 0;
166 }
else if (name ==
"stderr") {
168 cout <<
"G4HepRepSceneHandler::Open() stderr" << endl;
173 eventNumberPrefix =
"";
174 eventNumberSuffix =
"";
179 writeMultipleFiles =
false;
181 eventNumberWidth = 0;
184 cout <<
"G4HepRepSceneHandler::Open() " << name << endl;
186 if (eventNumberWidth < 0) {
189 const unsigned int numberOfExtensions = 8;
190 string ext[numberOfExtensions] = {
".heprep",
".heprep.xml",
".heprep.zip",
".heprep.gz",
191 ".bheprep",
".bheprep.xml",
".bheprep.zip",
".bheprep.gz"};
193 while (i < numberOfExtensions) {
194 int dot = name.size() - ext[i].size();
196 (name.substr(dot, ext[i].size()) == ext[i]))
break;
200 if (i != numberOfExtensions) {
202 writeBinary = i >= (numberOfExtensions/2);
203 writeZip = (i == 2) || (i == 6);
204 writeGZ = (i == 3) || (i == 7);
206 int dot = name.length() - extension.length();
207 baseName = (dot >= 0) ? name.substr(0, dot) :
"";
209 #ifndef G4LIB_USE_ZLIB
212 cerr <<
"WARNING: the .gz output file you are creating will be a plain file," << endl;
213 cerr <<
" since compression support (ZLIB) was not compiled into the Geant4." << endl;
214 cerr <<
" To avoid confusion with real gz files, the output filename has been" << endl;
215 cerr <<
" extended with the name '.no-gz'." << endl;
216 cerr <<
" A plain heprep or bheprep file can be fairly large." << endl;
220 cerr <<
"WARNING: the .zip output file you are creating will not be compressed," << endl;
221 cerr <<
" since compression support (ZLIB) was not compiled into the Geant4." << endl;
222 cerr <<
" A zip file containing non-compressed heprep or bheprep files can" << endl;
223 cerr <<
" be fairly large." << endl;
225 if (writeGZ || writeZip) {
226 cerr <<
"SOLUTION: To add compression support using ZLIB, you need to:" << endl;
227 cerr <<
" 1. Define G4LIB_USE_ZLIB and recompile the visualization category." << endl;
228 cerr <<
" 2. Optionally define G4_LIB_BUILD_ZLIB if your system does not have" << endl;
229 cerr <<
" zlib installed (e.g. WIN32-VC)." << endl;
230 cerr <<
" 3. Relink your application code." << endl;
234 extension = extension +
".no-gz";
237 #endif // G4LIB_USE_ZLIB
240 extension =
".heprep.zip";
247 writeMultipleFiles =
false;
248 int startDigit = -1;
int endDigit = -1;
255 endDigit = suffix.length()-1;
256 while (endDigit >= 0) {
257 if (isdigit(suffix.at(endDigit)))
break;
261 cerr <<
"/vis/heprep/appendEventNumberSuffix contains no digits" << endl;
263 writeMultipleFiles =
true;
264 startDigit = endDigit;
265 while (startDigit >= 0) {
266 if (!isdigit(suffix.at(startDigit)))
break;
273 if (writeMultipleFiles) {
274 eventNumberPrefix = suffix.substr(0, startDigit);
275 eventNumber = atoi(suffix.substr(startDigit, endDigit).c_str());
276 eventNumberWidth = endDigit +1 - startDigit;
277 eventNumberSuffix = suffix.substr(endDigit+1);
283 eventNumberWidth = 10;
284 eventNumberPrefix =
"";
285 eventNumberSuffix =
"";
294 cout <<
"G4HepRepSceneHandler::OpenHepRep() " << endl;
297 if (_heprep != NULL)
return;
300 _heprepGeometry = NULL;
301 _geometryInstanceTree = NULL;
302 _geometryRootInstance = NULL;
303 _geometryInstance.clear();
304 _geometryTypeTree = NULL;
305 _geometryRootType = NULL;
306 _geometryTypeName.clear();
307 _geometryType.clear();
308 _eventInstanceTree = NULL;
309 _eventInstance = NULL;
310 _eventTypeTree = NULL;
312 _trajectoryType = NULL;
315 _calHitFaceType = NULL;
323 if (_heprep == NULL)
return true;
326 cout <<
"G4HepRepSceneHandler::CloseHepRep() start" << endl;
331 if (_eventInstanceTree != NULL) {
332 cerr <<
"WARNING: you probably used '/vis/viewer/endOfEventAction accumulate' and "
333 <<
"forgot to call /vis/viewer/update before exit. No event written." << endl;
341 if (_eventInstanceTree != NULL) {
348 if ((_geometryInstanceTree != NULL)) {
353 if (writeMultipleFiles) {
354 sprintf(name,
"%s%s%s#%s", baseName.c_str(),
"-geometry", extension.c_str(),
"G4GeometryData");
356 sprintf(name,
"%s%s#%s",
"geometry", (writeBinary ?
".bheprep" :
".heprep"),
"G4GeometryData");
363 if (_eventInstanceTree != NULL) {
373 writeLayers(_heprepGeometry);
374 writeLayers(_heprep);
377 if (writer == NULL) {
383 if (writeMultipleFiles) {
385 sprintf(fileName,
"%s%s%s", baseName.c_str(),
"-geometry", extension.c_str());
390 sprintf(name,
"%s%s",
"geometry", (writeBinary ?
".bheprep" :
".heprep"));
391 if (!writeMultipleFiles) {
397 delete _heprepGeometry;
398 _heprepGeometry = NULL;
403 if (writeMultipleFiles) {
410 char fileFormat[128];
411 sprintf(fileFormat,
"%s%d%s",
"%s%s%0", eventNumberWidth,
"d%s%s");
412 sprintf(fileName, fileFormat, baseName.c_str(), eventNumberPrefix.c_str(), eventNumber, eventNumberSuffix.c_str(), extension.c_str());
423 char eventFormat[128];
424 sprintf(eventFormat,
"%s%d%s%s",
"event-%0", eventNumberWidth,
"d", (writeBinary ?
".bheprep" :
".heprep"));
425 sprintf(eventName, eventFormat, eventNumber);
440 void G4HepRepSceneHandler::close() {
443 cout <<
"G4HepRepSceneHandler::Close() " << endl;
446 if (writer == NULL)
return;
448 if (!writeMultipleFiles) {
458 out =
new ofstream(name.c_str(), std::ios::out | std::ios::binary );
471 void G4HepRepSceneHandler::writeLayers(
HepRep* heprep) {
472 if (heprep == NULL)
return;
482 cout <<
"G4HepRepSceneHandler::BeginModeling() " << endl;
490 cout <<
"G4HepRepSceneHandler::EndModeling() " << endl;
497 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Box& box)" << endl;
500 if (dontWrite())
return;
522 vertex1 = (transform) * vertex1;
523 vertex2 = (transform) * vertex2;
524 vertex3 = (transform) * vertex3;
525 vertex4 = (transform) * vertex4;
526 vertex5 = (transform) * vertex5;
527 vertex6 = (transform) * vertex6;
528 vertex7 = (transform) * vertex7;
529 vertex8 = (transform) * vertex8;
531 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
532 addAttributes(instance, getCalHitType());
534 setAttribute(instance,
"DrawAs",
G4String(
"Prism"));
536 setVisibility(instance, box);
537 setLine(instance, box);
538 setColor(instance, getColorFor(box));
553 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Cons& cons)" << endl;
556 if (dontWrite())
return;
579 vertex1 = (transform) * vertex1;
580 vertex2 = (transform) * vertex2;
582 HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
583 setAttribute(instance,
"DrawAs",
G4String(
"Cylinder"));
585 setVisibility(instance, cons);
586 setLine(instance, cons);
587 setColor(instance, getColorFor(cons));
594 outer->addAttValue(
"showParentAttributes",
true);
617 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Tubs& tubs)" << endl;
620 if (dontWrite())
return;
643 vertex1 = (transform) * vertex1;
644 vertex2 = (transform) * vertex2;
646 HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
647 setAttribute(instance,
"DrawAs",
G4String(
"Cylinder"));
649 setVisibility(instance, tubs);
650 setLine(instance, tubs);
651 setColor(instance, getColorFor(tubs));
658 outer->addAttValue(
"pickParent",
true);
659 outer->addAttValue(
"showParentAttributes",
true);
677 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Trd& trd)" << endl;
679 if (dontWrite())
return;
703 vertex1 = (transform) * vertex1;
704 vertex2 = (transform) * vertex2;
705 vertex3 = (transform) * vertex3;
706 vertex4 = (transform) * vertex4;
707 vertex5 = (transform) * vertex5;
708 vertex6 = (transform) * vertex6;
709 vertex7 = (transform) * vertex7;
710 vertex8 = (transform) * vertex8;
712 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
714 addAttributes(instance, getCalHitType());
716 setAttribute(instance,
"DrawAs",
G4String(
"Prism"));
718 setVisibility(instance, trd);
719 setLine(instance, trd);
720 setColor(instance, getColorFor(trd));
733 if (dontWrite())
return;
738 if (dontWrite())
return;
743 if (dontWrite())
return;
748 if (dontWrite())
return;
753 if (dontWrite())
return;
758 if (dontWrite())
return;
763 if (dontWrite())
return;
771 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Polyline&) " << line.size() << endl;
773 if (dontWrite())
return;
776 static G4bool warned =
false;
780 (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyline&)",
782 "2D polylines not implemented. Ignored.");
789 addAttributes(instance, getTrajectoryType());
793 setVisibility(instance, line);
795 setLine(instance, line);
797 for (
size_t i=0; i < line.size(); i++) {
807 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Polymarker&) " << line.size() << endl;
809 if (dontWrite())
return;
812 static G4bool warned =
false;
816 (
"G4HepRepSceneHandler::AddPrimitive (const G4Polymarker&)",
818 "2D polymarkers not implemented. Ignored.");
825 addAttributes(instance, getHitType());
829 setVisibility(instance, line);
831 setMarker(instance, line);
837 if (mtype == line.
dots) {
838 setAttribute(instance,
"Fill",
true);
840 }
else if (mtype == line.
circles) {
842 setAttribute(instance,
"MarkName",
G4String(
"Box"));
845 setAttribute(instance,
"MarkName",
G4String(
"Plus"));
848 for (
size_t i=0; i < line.size(); i++) {
857 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Circle&) " << endl;
859 if (dontWrite())
return;
862 static G4bool warned =
false;
866 (
"G4HepRepSceneHandler::AddPrimitive (const G4Circle&)",
868 "2D circles not implemented. Ignored.");
875 addAttributes(instance, getHitType());
879 setColor (instance,
GetColor(circle));
881 setVisibility(instance, circle);
883 setMarker(instance, circle);
892 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Polyhedron&) " << endl;
894 if (dontWrite())
return;
897 static G4bool warned =
false;
901 (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyhedron&)",
903 "2D polyhedra not implemented. Ignored.");
913 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
915 addAttributes(instance, getCalHitType());
917 setVisibility(instance, polyhedron);
919 G4int currentDepth = 0;
930 face = getGeometryInstance(
"*Face", currentDepth+1);
931 setAttribute(face,
"PickParent",
true);
932 setAttribute(face,
"DrawAs",
G4String(
"Polygon"));
935 setLine(face, polyhedron);
936 setColor(face,
GetColor(polyhedron));
937 if (isEventData()) setColor(face,
GetColor(polyhedron),
G4String(
"FillColor"));
945 vertex = transform * vertex;
947 }
while (notLastEdge);
948 }
while (notLastFace);
954 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Text&) " << endl;
956 if (dontWrite())
return;
972 cout <<
"G4HepRepSceneHandler::AddPrimitive G4Text : not yet implemented. " << endl;
978 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Square&) " << endl;
980 if (dontWrite())
return;
983 static G4bool warned =
false;
987 (
"G4HepRepSceneHandler::AddPrimitive (const G4Square&)",
989 "2D squares not implemented. Ignored.");
996 addAttributes(instance, getHitType());
1000 setColor (instance, getColorFor(square));
1002 setVisibility(instance, square);
1004 setMarker(instance, square);
1011 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4NURBS&) " << endl;
1013 if (dontWrite())
return;
1029 cout <<
"G4HepRepSceneHandler::AddPrimitive G4NURBS : not yet implemented. " << endl;
1033 if (dontWrite())
return;
1039 cout <<
"G4HepRepSceneHandler::AddCompound(G4VTrajectory&) " << endl;
1041 if (dontWrite())
return;
1043 currentTrack = &trajectory;
1045 currentTrack = NULL;
1051 cout <<
"G4HepRepSceneHandler::AddCompound(G4VHit&) " << endl;
1053 if (dontWrite())
return;
1065 transform = objectTransformation;
1067 cout <<
"G4HepRepSceneHandler::PreAddSolid(G4Transform3D&, G4VisAttributes&)" << endl;
1074 cout <<
"G4HepRepSceneHandler::PostAddSolid()" << endl;
1082 cout <<
"G4HepRepSceneHandler::BeginPrimitives(G4Transform3D&)" << endl;
1086 transform = objectTransformation;
1092 cout <<
"G4HepRepSceneHandler::EndPrimitives" << endl;
1098 G4bool G4HepRepSceneHandler::dontWrite() {
1107 cout <<
"G4HepRepSceneHandler::setColor : red : " << color.
GetRed () <<
1108 " green : " << color.
GetGreen () <<
1109 " blue : " << color.
GetBlue () << endl;
1130 setAttribute(attribute,
"Visibility", (atts && (atts->
IsVisible()==0)) ?
false :
true);
1134 setAttribute(attribute,
"LineWidth", 1.0);
1140 setAttribute(attribute,
"LineWidth", (atts != NULL) ? atts->
GetLineWidth() : 1.0);
1145 setAttribute(attribute,
"LineStyle",
G4String(
"Dotted"));
1148 setAttribute(attribute,
"LineStyle",
G4String(
"Dashed"));
1161 setAttribute(attribute,
"MarkSize", size);
1163 if (markerType ==
screen) setAttribute(attribute,
"MarkType",
G4String(
"Symbol"));
1165 setAttribute(attribute,
"Fill",
false);
1174 const map<G4String,G4AttDef>* hitAttDefs = currentHit->
GetAttDefs();
1176 addAttDefs(getHitType(), hitAttDefs);
1187 addAttVals(instance, hitAttDefs, hitAttValues);
1189 delete hitAttValues;
1191 }
else if (currentTrack) {
1192 vector<G4AttValue>* trajectoryAttValues = currentTrack->
CreateAttValues();
1193 const map<G4String,G4AttDef>* trajectoryAttDefs = currentTrack->
GetAttDefs();
1195 addAttDefs(type, trajectoryAttDefs);
1207 addAttVals(instance, trajectoryAttDefs, trajectoryAttValues);
1209 delete trajectoryAttValues;
1218 if (point != NULL) {
1225 if (instance != NULL) {
1228 attribute = instance->
getType();
1240 if (point != NULL) {
1247 if (instance != NULL) {
1250 attribute = instance->
getType();
1262 if (point != NULL) {
1269 if (instance != NULL) {
1272 attribute = instance->
getType();
1284 if (point != NULL) {
1291 if (instance != NULL) {
1294 attribute = instance->
getType();
1304 vector<double> color;
1305 if (attValue != NULL) color = attValue->
getColor();
1306 if ((color.size() == 0) ||
1307 (color[0] != red) ||
1308 (color[1] != green) ||
1309 (color[2] != blue) ||
1310 ((color.size() > 3) && (color[3] != alpha))) {
1313 if (point != NULL) {
1320 if (instance != NULL) {
1323 attribute = instance->
getType();
1327 attribute->
addAttValue(name, red, green, blue, alpha);
1331 void G4HepRepSceneHandler::addAttDefs(
HepRepDefinition* definition,
const map<G4String,G4AttDef>* attDefs) {
1332 if (attDefs == NULL)
return;
1335 map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->begin();
1336 while (attDefIterator != attDefs->end()) {
1337 definition->
addAttDef(attDefIterator->first, attDefIterator->second.GetDesc(),
1338 attDefIterator->second.GetCategory(), attDefIterator->second.GetExtra());
1343 void G4HepRepSceneHandler::addAttVals(
HepRepAttribute* attribute,
const map<G4String,G4AttDef>* attDefs, vector<G4AttValue>* attValues) {
1344 if (attValues == NULL)
return;
1347 for (vector<G4AttValue>::iterator attValIterator = attValues->begin(); attValIterator != attValues->end(); attValIterator++) {
1348 G4String name = attValIterator->GetName();
1351 if ((name ==
"Pos") && (point != NULL)) {
1352 G4String pos = attValIterator->GetValue();
1358 for (
unsigned int i=0; i<pos.length(); i++) {
1359 if (pos[i] ==
' ') {
1362 double factor = atof(pos.substr(is, i-is).c_str())/point->
getX();
1363 im = (
int)(std::log10(factor)+((factor < 1) ? -0.5 : 0.5));
1365 }
else if (in == 3) {
1367 unit = pos.substr(is, i-is);
1370 }
else if (unit ==
G4String(
"mm")) {
1372 }
else if (unit ==
G4String(
"cm")) {
1374 }
else if (unit ==
G4String(
"m")) {
1376 }
else if (unit ==
G4String(
"km")) {
1379 cerr <<
"HepRepSceneHandler: Unrecognized Unit: '" << unit <<
"'" << endl;
1403 cerr <<
"HepRepSceneHandler: No valid unit found for im: " << im << endl;
1408 setAttribute(attribute,
G4String(
"PointUnit"), unit);
1413 if (name ==
"NTP")
continue;
1416 const map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->find(name);
1417 G4String type = attDefIterator->second.GetValueType();
1420 if ((type ==
"G4double") || (type ==
"double")) {
1421 setAttribute(attribute, attValIterator->GetName(), atof(attValIterator->GetValue()));
1422 }
else if ((type ==
"G4int") || (type ==
"int")) {
1423 setAttribute(attribute, attValIterator->GetName(), atoi(attValIterator->GetValue()));
1425 setAttribute(attribute, attValIterator->GetName(), attValIterator->GetValue());
1431 bool G4HepRepSceneHandler::isEventData () {
1437 void G4HepRepSceneHandler::addTopLevelAttributes(
HepRepType* type) {
1440 type->
addAttDef(
"Generator",
"Generator of the file",
"General",
"");
1443 type->
addAttDef(
"GeneratorVersion",
"Version of the Generator",
"General",
"");
1444 G4String versionString = G4Version;
1445 versionString = versionString.substr(1,versionString.size()-2);
1446 versionString =
" Geant4 version " + versionString +
" " + G4Date;
1447 type->
addAttValue(
"GeneratorVersion", versionString);
1451 type->
addAttDef(
"ViewTheta",
"Theta of initial suggested viewpoint",
"Draw",
"rad");
1454 type->
addAttDef(
"ViewPhi",
"Phi of initial suggested viewpoint",
"Draw",
"rad");
1457 type->
addAttDef(
"ViewScale",
"Scale of initial suggested viewpoint",
"Draw",
"");
1461 type->
addAttDef(
"ViewTranslateX",
"Translate in X of initial suggested viewpoint",
"Draw",
"");
1464 type->
addAttDef(
"ViewTranslateY",
"Translate in Y of initial suggested viewpoint",
"Draw",
"");
1467 type->
addAttDef(
"ViewTranslateZ",
"Translate in Z of initial suggested viewpoint",
"Draw",
"");
1470 type->
addAttDef(
"PointUnit",
"Length",
"Physics",
"");
1475 type->
addAttDef(
"UseSolids",
"Use HepRep Solids rather than Geant4 Primitives",
"Draw",
"");
1478 type->
addAttDef(
"WriteInvisibles",
"Write Invisible Objects",
"Draw",
"");
1484 if (isEventData()) {
1492 return getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
1496 HepRep* G4HepRepSceneHandler::getHepRep() {
1497 if (_heprep == NULL) {
1504 HepRep* G4HepRepSceneHandler::getHepRepGeometry() {
1505 if (_heprepGeometry == NULL) {
1509 return _heprepGeometry;
1513 if (_geometryInstanceTree == NULL) {
1524 return _geometryInstanceTree;
1527 HepRepInstance* G4HepRepSceneHandler::getGeometryRootInstance() {
1528 if (_geometryRootInstance == NULL) {
1530 _geometryRootInstance = factory->
createHepRepInstance(getGeometryInstanceTree(), getGeometryRootType());
1532 return _geometryRootInstance;
1538 setAttribute(instance,
"LVol", volume->
GetName());
1541 setAttribute(instance,
"Region", regionName);
1542 setAttribute(instance,
"RootRegion", volume->
IsRootRegion());
1546 setAttribute(instance,
"Material", matName );
1548 setAttribute(instance,
"Density", matDensity);
1550 setAttribute(instance,
"Radlen", matRadlen);
1553 G4String state = materialState[matState];
1554 setAttribute(instance,
"State", state);
1563 while ((
int)_geometryInstance.size() > depth) {
1564 _geometryInstance.pop_back();
1568 HepRepInstance* parent = (_geometryInstance.empty()) ? getGeometryRootInstance() : _geometryInstance.back();
1571 HepRepType* type = getGeometryType(volumeName, depth);
1575 _geometryInstance.push_back(instance);
1581 if (_geometryTypeTree == NULL) {
1590 getHepRepGeometry()->
addTypeTree(_geometryTypeTree);
1593 return _geometryTypeTree;
1596 HepRepType* G4HepRepSceneHandler::getGeometryRootType() {
1597 if (_geometryRootType == NULL) {
1599 _geometryRootType = factory->
createHepRepType(getGeometryTypeTree(), rootVolumeName);
1600 _geometryRootType->
addAttValue(
"Layer", geometryLayer);
1603 _geometryRootType->
addAttDef (
"LVol",
"Logical Volume",
"Physics",
"");
1605 _geometryRootType->
addAttDef (
"Region",
"Cuts Region",
"Physics",
"");
1607 _geometryRootType->
addAttDef (
"RootRegion",
"Root Region",
"Physics",
"");
1608 _geometryRootType->
addAttValue(
"RootRegion",
false);
1609 _geometryRootType->
addAttDef (
"Solid",
"Solid Name",
"Physics",
"");
1611 _geometryRootType->
addAttDef (
"EType",
"Entity Type",
"Physics",
"");
1613 _geometryRootType->
addAttDef (
"Material",
"Material Name",
"Physics",
"");
1615 _geometryRootType->
addAttDef (
"Density",
"Material Density",
"Physics",
"");
1617 _geometryRootType->
addAttDef (
"State",
"Material State",
"Physics",
"");
1619 _geometryRootType->
addAttDef (
"Radlen",
"Material Radiation Length",
"Physics",
"");
1623 _geometryRootType->
addAttValue(
"Color", 0.8, 0.8, 0.8, 1.0);
1624 _geometryRootType->
addAttValue(
"Visibility",
true);
1625 _geometryRootType->
addAttValue(
"FillColor", 0.8, 0.8, 0.8, 1.0);
1628 _geometryRootType->
addAttValue(
"PickParent",
false);
1629 _geometryRootType->
addAttValue(
"ShowParentAttributes",
true);
1631 _geometryRootType->
addAttValue(
"MarkSizeMultiplier", 4.0);
1632 _geometryRootType->
addAttValue(
"LineWidthMultiplier", 1.0);
1634 addTopLevelAttributes(_geometryRootType);
1636 _geometryType[
"/"+_geometryRootType->
getName()] = _geometryRootType;
1638 return _geometryRootType;
1643 getGeometryRootType();
1646 G4String name = getFullTypeName(volumeName, depth);
1651 G4String parentName = getParentTypeName(depth);
1652 HepRepType* parentType = _geometryType[parentName];
1655 _geometryType[
name] = type;
1660 G4String G4HepRepSceneHandler::getFullTypeName(
G4String volumeName,
int depth) {
1662 if (depth > (
int)_geometryTypeName.size()) {
1664 G4String problem =
"HierarchyProblem";
1665 if (_geometryType[
"/"+problem] == NULL) {
1668 _geometryType[
"/"+problem] = type;
1670 return "/" + problem +
"/" + volumeName;
1674 while ((
int)_geometryTypeName.size() > depth) {
1675 _geometryTypeName.pop_back();
1679 G4String name = (_geometryTypeName.empty()) ?
G4String(
"/"+rootVolumeName) : _geometryTypeName.back();
1680 name = name +
"/" + volumeName;
1681 _geometryTypeName.push_back(name);
1685 G4String G4HepRepSceneHandler::getParentTypeName(
int depth) {
1686 return (depth >= 1) ? _geometryTypeName[depth-1] :
G4String(
"/"+rootVolumeName);
1690 if (_eventInstanceTree == NULL) {
1695 return _eventInstanceTree;
1699 if (_eventInstance == NULL) {
1703 return _eventInstance;
1707 if (_eventTypeTree == NULL) {
1714 return _eventTypeTree;
1717 HepRepType* G4HepRepSceneHandler::getEventType() {
1718 if (_eventType == NULL) {
1725 _eventType->
addAttValue(
"Color", 1.0, 1.0, 1.0, 1.0);
1726 _eventType->
addAttValue(
"FillColor", 1.0, 1.0, 1.0, 1.0);
1730 _eventType->
addAttValue(
"ShowParentAttributes",
false);
1732 _eventType->
addAttValue(
"MarkSizeMultiplier", 4.0);
1733 _eventType->
addAttValue(
"LineWidthMultiplier", 1.0);
1735 addTopLevelAttributes(_eventType);
1741 HepRepType* G4HepRepSceneHandler::getTrajectoryType() {
1742 if (_trajectoryType == NULL) {
1745 _trajectoryType->
addAttValue(
"Layer", trajectoryLayer);
1748 _trajectoryType->
addAttValue(
"LineWidthMultiplier", 2.0);
1756 return _trajectoryType;
1759 HepRepType* G4HepRepSceneHandler::getHitType() {
1760 if (_hitType == NULL) {
1772 HepRepType* G4HepRepSceneHandler::getCalHitType() {
1773 if (_calHitType == NULL) {
1782 HepRepType* G4HepRepSceneHandler::getCalHitFaceType() {
1783 if (_calHitFaceType == NULL) {
1784 _calHitFaceType = factory->
createHepRepType(getCalHitType(),
"CalHitFace");
1787 return _calHitFaceType;