Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
JA Namespace Reference

Classes

struct  Node
 

Typedefs

typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
 
typedef std::vector< PVNodeIDPVPath
 

Functions

void Insert (const PVNodeID *pvPath, size_t pathLength, G4int index, Node *node)
 
void PrintTree (std::ostream &, Node *)
 
void Clear (Node *)
 

Typedef Documentation

◆ PVNodeID

◆ PVPath

typedef std::vector<PVNodeID> JA::PVPath

Definition at line 46 of file G4XXXSGSceneHandler.hh.

Function Documentation

◆ Clear()

void JA::Clear ( Node node)

Definition at line 494 of file G4XXXSGSceneHandler.cc.

495{
496 const size_t& nDaughters = node->fDaughters.size();
497 for (size_t i = 0; i < nDaughters; ++i) {
498 Clear(node->fDaughters[i]);
499 delete node->fDaughters[i];
500 }
501}
void Clear(Node *)
std::vector< Node * > fDaughters

Referenced by Clear(), G4XXXSGSceneHandler::ClearStore(), and G4XXXSGSceneHandler::ClearTransientStore().

◆ Insert()

void JA::Insert ( const PVNodeID pvPath,
size_t  pathLength,
G4int  index,
Node node 
)

Definition at line 427 of file G4XXXSGSceneHandler.cc.

428 {
429 // Path passed as a PVNodeID* to avoid copying.
430
431 /* Debug
432 for (size_t i = 0; i < pathLength; ++i) {
433 std::cout << pvPath[i].GetPhysicalVolume()->GetName() << ":"
434 << pvPath[i].GetCopyNo() << " ("
435 << index << "), ";
436 }
437 */
438
439 // See if node has been encountered before
440 G4bool found = false; size_t foundPosition = 0;
441 for (size_t i = 0; i < node->fDaughters.size(); ++i) {
442 PVNodeID& daughterPVNodeID = node->fDaughters[i]->fPVNodeID;
443 // It is enough to compare volume and copy number at a given position in the tree
444 if (daughterPVNodeID.GetPhysicalVolume() == pvPath[0].GetPhysicalVolume() &&
445 daughterPVNodeID.GetCopyNo() == pvPath[0].GetCopyNo()) {
446 found = true;
447 foundPosition = i;
448 break;
449 }
450 }
451
452 if (pathLength == 1) { // This is a leaf
453 if (found) { // Update index
454 node->fDaughters[foundPosition]->fIndex = index;
455 } else { // Make a new full entry
456 node->fDaughters.push_back(new Node(pvPath[0],index));
457 }
458 /* Debug
459 std::cout << std::endl;
460 */
461 } else { // Not a leaf - carry on with rest of path
462 if (found) { // Just carry on
463 Insert(pvPath+1,--pathLength,index,
464 node->fDaughters[foundPosition]);
465 } else { // Insert place holder, then carry on
466 node->fDaughters.push_back(new Node(pvPath[0]));
467 Insert(pvPath+1,--pathLength,index,
468 node->fDaughters[node->fDaughters.size()-1]);
469 }
470 }
471}
bool G4bool
Definition: G4Types.hh:67
void Insert(const PVNodeID *pvPath, size_t pathLength, G4int index, Node *node)

Referenced by G4XXXSGSceneHandler::CreateCurrentItem(), and Insert().

◆ PrintTree()

void JA::PrintTree ( std::ostream &  os,
Node node 
)

Definition at line 473 of file G4XXXSGSceneHandler.cc.

474{
475 static G4int depth = -1;
476 depth++;
477 PVNodeID& thisPVNodeID = node->fPVNodeID;
478 G4int& thisIndex = node->fIndex;
479 const size_t& nDaughters = node->fDaughters.size();
480 G4VPhysicalVolume* thisPhysicalVolume= thisPVNodeID.GetPhysicalVolume();
481 if (!thisPhysicalVolume) os << "Root" << std::endl;
482 else {
483 for (G4int i = 0; i < depth; ++i) os << "__";
484 os << thisPVNodeID.GetPhysicalVolume()->GetName() << ":"
485 << thisPVNodeID.GetCopyNo() << " ("
486 << thisIndex << ")" << std::endl;;
487 }
488 for (size_t i = 0; i < nDaughters; ++i) {
489 PrintTree(os, node->fDaughters[i]);
490 }
491 depth--;
492}
int G4int
Definition: G4Types.hh:66
const G4String & GetName() const
PVNodeID fPVNodeID

Referenced by G4XXXSGViewer::DrawFromStore(), and PrintTree().