CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CheckOverlap Class Reference

#include <CheckOverlap.h>

Inheritance diagram for CheckOverlap:
SimWatcher Observer< const BeginOfRun *>

Public Member Functions

 CheckOverlap (edm::ParameterSet const &p)
 
 ~CheckOverlap () override
 
- Public Member Functions inherited from SimWatcher
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfRun *>
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 

Private Member Functions

void checkHierarchyLeafPVLV (G4LogicalVolume *lv, unsigned int leafDepth)
 
void checkPV (G4VPhysicalVolume *pv, unsigned int leafDepth)
 
void dumpLV (G4LogicalVolume *lv, std::string str)
 
G4VPhysicalVolume * getTopPV ()
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

std::vector< std::string > nodeNames
 
int nPoints
 
std::vector< G4LogicalVolume * > topLV
 

Additional Inherited Members

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 18 of file CheckOverlap.h.

Constructor & Destructor Documentation

◆ CheckOverlap()

CheckOverlap::CheckOverlap ( edm::ParameterSet const &  p)

Definition at line 20 of file CheckOverlap.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, cuy::ii, nodeNames, nPoints, and AlCaHLTBitMon_ParallelJobs::p.

20  : topLV(0) {
21  std::vector<std::string> defNames;
22  nodeNames = p.getUntrackedParameter<std::vector<std::string> >("NodeNames", defNames);
23  nPoints = p.getUntrackedParameter<int>("Resolution", 1000);
24  G4cout << "CheckOverlap:: initialised with " << nodeNames.size() << " Node Names and Resolution " << nPoints
25  << " the names are:" << G4endl;
26  for (unsigned int ii = 0; ii < nodeNames.size(); ii++)
27  G4cout << "CheckOverlap:: Node[" << ii << "] : " << nodeNames[ii] << G4endl;
28 }
std::vector< std::string > nodeNames
Definition: CheckOverlap.h:31
ii
Definition: cuy.py:589
std::vector< G4LogicalVolume * > topLV
Definition: CheckOverlap.h:33

◆ ~CheckOverlap()

CheckOverlap::~CheckOverlap ( )
override

Definition at line 30 of file CheckOverlap.cc.

30 {}

Member Function Documentation

◆ checkHierarchyLeafPVLV()

void CheckOverlap::checkHierarchyLeafPVLV ( G4LogicalVolume *  lv,
unsigned int  leafDepth 
)
private

Definition at line 64 of file CheckOverlap.cc.

References checkPV().

Referenced by update().

64  {
65  //----- Get LV daughters from list of PV daughters
66  mmlvpv lvpvDaughters;
67  std::set<G4LogicalVolume*> lvDaughters;
68  int NoDaughters = lv->GetNoDaughters();
69  while ((NoDaughters--) > 0) {
70  G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
71  lvpvDaughters.insert(mmlvpv::value_type(pvD->GetLogicalVolume(), pvD));
72  lvDaughters.insert(pvD->GetLogicalVolume());
73  }
74 
75  std::set<G4LogicalVolume*>::const_iterator scite;
76  mmlvpv::const_iterator mmcite;
77 
78  //----- Check daughters of LV
79  for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
80  std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
81  //----- Check daughters PV of this LV
82  for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
83  checkPV((*mmcite).second, leafDepth + 1);
84  //----- Check daughters LV
85  checkHierarchyLeafPVLV(*scite, leafDepth + 1);
86  }
87 }
void checkPV(G4VPhysicalVolume *pv, unsigned int leafDepth)
Definition: CheckOverlap.cc:89
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
void checkHierarchyLeafPVLV(G4LogicalVolume *lv, unsigned int leafDepth)
Definition: CheckOverlap.cc:64

◆ checkPV()

void CheckOverlap::checkPV ( G4VPhysicalVolume *  pv,
unsigned int  leafDepth 
)
private

Definition at line 89 of file CheckOverlap.cc.

References dumpLV(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, nPoints, convertSQLiteXML::ok, MetAnalyzer::pv(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by checkHierarchyLeafPVLV().

89  {
90  //----- PV info
91 #ifndef G4V7
92  std::string mother = "DDDWorld";
93  if (pv->GetMotherLogical())
94  mother = pv->GetMotherLogical()->GetName();
95  if (!pv->IsReplicated()) {
96  G4PVPlacement* pvplace = dynamic_cast<G4PVPlacement*>(pv);
97  G4bool ok = pvplace->CheckOverlaps(nPoints);
98  G4cout << "Placed PV " << pvplace->GetName() << " Number " << pvplace->GetCopyNo() << " in mother " << mother
99  << " at depth " << leafDepth << " Status " << ok << G4endl;
100  if (ok) {
101  if (pv->GetRotation() == nullptr) {
102  G4cout << "Translation " << pv->GetTranslation() << " and with no rotation" << G4endl;
103  } else {
104  G4cout << "Translation " << pv->GetTranslation() << " and with rotation " << *(pv->GetRotation()) << G4endl;
105  }
106  G4LogicalVolume* lv = pv->GetLogicalVolume();
107  dumpLV(lv, "Self");
108  if (pv->GetMotherLogical()) {
109  lv = pv->GetMotherLogical();
110  dumpLV(lv, "Mother");
111  }
112  }
113  } else {
114  if (pv->GetParameterisation() != nullptr) {
115  G4PVParameterised* pvparam = dynamic_cast<G4PVParameterised*>(pv);
116  G4bool ok = pvparam->CheckOverlaps(nPoints);
117  G4cout << "Parametrized PV " << pvparam->GetName() << " in mother " << mother << " at depth " << leafDepth
118  << " Status " << ok << G4endl;
119  }
120  }
121 #endif
122 }
void dumpLV(G4LogicalVolume *lv, std::string str)
def pv(vc)
Definition: MetAnalyzer.py:7

◆ dumpLV()

void CheckOverlap::dumpLV ( G4LogicalVolume *  lv,
std::string  str 
)
private

Definition at line 128 of file CheckOverlap.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, and str.

Referenced by checkPV().

128  {
129  G4cout << "Dump of " << str << " Logical Volume " << lv->GetName() << " Solid: " << lv->GetSolid()->GetName()
130  << " Material: " << lv->GetMaterial()->GetName() << G4endl;
131  G4cout << *(lv->GetSolid()) << G4endl;
132 }
#define str(s)

◆ getTopPV()

G4VPhysicalVolume * CheckOverlap::getTopPV ( )
private

Definition at line 124 of file CheckOverlap.cc.

Referenced by update().

124  {
125  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
126 }

◆ update()

void CheckOverlap::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 32 of file CheckOverlap.cc.

References checkHierarchyLeafPVLV(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getTopPV(), mps_fire::i, cuy::ii, nodeNames, and topLV.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

32  {
33  if (!nodeNames.empty()) {
34  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
35  G4cout << "CheckOverlap::update nLV= " << lvs->size() << G4endl;
36  std::vector<G4LogicalVolume*>::const_iterator lvcite;
37  int i = 0;
38  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
39  for (unsigned int ii = 0; ii < nodeNames.size(); ii++) {
40  if ((*lvcite)->GetName() == (G4String)(nodeNames[ii])) {
41  topLV.push_back((*lvcite));
42  break;
43  }
44  }
45  G4cout << "Name of node " << (++i) << " : " << (*lvcite)->GetName() << G4endl;
46  if (topLV.size() == nodeNames.size())
47  break;
48  }
49  } else {
50  G4VPhysicalVolume* theTopPV = getTopPV();
51  topLV.push_back(theTopPV->GetLogicalVolume());
52  }
53 
54  if (topLV.empty()) {
55  G4cout << "No Top LV Found" << G4endl;
56  } else {
57  for (unsigned int ii = 0; ii < topLV.size(); ++ii) {
58  G4cout << "Top LV Name " << topLV[ii]->GetName() << G4endl;
60  }
61  }
62 }
void checkHierarchyLeafPVLV(G4LogicalVolume *lv, unsigned int leafDepth)
Definition: CheckOverlap.cc:64
std::vector< std::string > nodeNames
Definition: CheckOverlap.h:31
ii
Definition: cuy.py:589
G4VPhysicalVolume * getTopPV()
std::vector< G4LogicalVolume * > topLV
Definition: CheckOverlap.h:33

Member Data Documentation

◆ nodeNames

std::vector<std::string> CheckOverlap::nodeNames
private

Definition at line 31 of file CheckOverlap.h.

Referenced by CheckOverlap(), and update().

◆ nPoints

int CheckOverlap::nPoints
private

Definition at line 32 of file CheckOverlap.h.

Referenced by CheckOverlap(), and checkPV().

◆ topLV

std::vector<G4LogicalVolume *> CheckOverlap::topLV
private

Definition at line 33 of file CheckOverlap.h.

Referenced by update().