Geant4 10.7.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 45 of file G4XXXSGSceneHandler.hh.

Function Documentation

◆ Clear()

void JA::Clear ( Node node)

Definition at line 479 of file G4XXXSGSceneHandler.cc.

480{
481 const size_t& nDaughters = node->fDaughters.size();
482 for (size_t i = 0; i < nDaughters; ++i) {
483 Clear(node->fDaughters[i]);
484 delete node->fDaughters[i];
485 }
486}
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 412 of file G4XXXSGSceneHandler.cc.

413 {
414 // Path passed as a PVNodeID* to avoid copying.
415
416 /* Debug
417 for (size_t i = 0; i < pathLength; ++i) {
418 std::cout << pvPath[i].GetPhysicalVolume()->GetName() << ":"
419 << pvPath[i].GetCopyNo() << " ("
420 << index << "), ";
421 }
422 */
423
424 // See if node has been encountered before
425 G4bool found = false; size_t foundPosition = 0;
426 for (size_t i = 0; i < node->fDaughters.size(); ++i) {
427 PVNodeID& daughterPVNodeID = node->fDaughters[i]->fPVNodeID;
428 // It is enough to compare volume and copy number at a given position in the tree
429 if (daughterPVNodeID.GetPhysicalVolume() == pvPath[0].GetPhysicalVolume() &&
430 daughterPVNodeID.GetCopyNo() == pvPath[0].GetCopyNo()) {
431 found = true;
432 foundPosition = i;
433 break;
434 }
435 }
436
437 if (pathLength == 1) { // This is a leaf
438 if (found) { // Update index
439 node->fDaughters[foundPosition]->fIndex = index;
440 } else { // Make a new full entry
441 node->fDaughters.push_back(new Node(pvPath[0],index));
442 }
443 /* Debug
444 std::cout << std::endl;
445 */
446 } else { // Not a leaf - carry on with rest of path
447 if (found) { // Just carry on
448 Insert(pvPath+1,--pathLength,index,
449 node->fDaughters[foundPosition]);
450 } else { // Insert place holder, then carry on
451 node->fDaughters.push_back(new Node(pvPath[0]));
452 Insert(pvPath+1,--pathLength,index,
453 node->fDaughters[node->fDaughters.size()-1]);
454 }
455 }
456}
bool G4bool
Definition: G4Types.hh:86
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 458 of file G4XXXSGSceneHandler.cc.

459{
460 static G4int depth = -1;
461 depth++;
462 PVNodeID& thisPVNodeID = node->fPVNodeID;
463 G4int& thisIndex = node->fIndex;
464 const size_t& nDaughters = node->fDaughters.size();
465 G4VPhysicalVolume* thisPhysicalVolume= thisPVNodeID.GetPhysicalVolume();
466 if (!thisPhysicalVolume) os << "Root" << std::endl;
467 else {
468 for (G4int i = 0; i < depth; ++i) os << "__";
469 os << thisPVNodeID.GetPhysicalVolume()->GetName() << ":"
470 << thisPVNodeID.GetCopyNo() << " ("
471 << thisIndex << ")" << std::endl;;
472 }
473 for (size_t i = 0; i < nDaughters; ++i) {
474 PrintTree(os, node->fDaughters[i]);
475 }
476 depth--;
477}
int G4int
Definition: G4Types.hh:85
const G4String & GetName() const
PVNodeID fPVNodeID

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