CMS 3D CMS Logo

List of all members | Public Member Functions
G4CheckOverlap Class Reference

#include <G4CheckOverlap.h>

Public Member Functions

 G4CheckOverlap (edm::ParameterSet const &p)
 
 ~G4CheckOverlap ()
 

Detailed Description

Definition at line 6 of file G4CheckOverlap.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file G4CheckOverlap.cc.

References egammaForCoreTracking_cff::depth, relativeConstraints::empty, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, g4SimHits_cfi::gdmlFlag, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, cuy::ii, gen::k, hcalDigis_cfi::level, g4SimHits_cfi::LVname, groupFilesInBlocks::nn, np, MetAnalyzer::pv(), g4SimHits_cfi::PVname, AlCaHLTBitMon_QueryRunRegistry::string, PFTauMVAInputDiscriminatorTranslator_cfi::test, and tolerance.

18  {
19  std::vector<std::string> nodeNames = p.getParameter<std::vector<std::string>>("NodeNames");
20  std::string PVname = p.getParameter<std::string>("PVname");
21  std::string LVname = p.getParameter<std::string>("LVname");
22  double tolerance = p.getUntrackedParameter<double>("Tolerance", 0.0) * CLHEP::mm;
23  int nPoints = p.getUntrackedParameter<int>("Resolution", 10000);
24  bool verbose = p.getUntrackedParameter<bool>("Verbose", true);
25  bool regionFlag = p.getUntrackedParameter<bool>("RegionFlag", true);
26  bool gdmlFlag = p.getUntrackedParameter<bool>("gdmlFlag", false);
27  int nPrints = p.getUntrackedParameter<int>("ErrorThreshold", 1);
28  int level = p.getUntrackedParameter<int>("Level", 0);
29  int depth = p.getUntrackedParameter<int>("Depth", -1);
30 
31  const G4RegionStore *regStore = G4RegionStore::GetInstance();
32 
33  G4LogicalVolume *lv;
34  const G4PhysicalVolumeStore *pvs = G4PhysicalVolumeStore::GetInstance();
35  const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
36  unsigned int numPV = pvs->size();
37  unsigned int numLV = lvs->size();
38  unsigned int nn = nodeNames.size();
39 
40  std::vector<G4String> savedgdml;
41 
42  G4cout << "G4OverlapCheck is initialised with " << nodeNames.size() << " nodes; "
43  << " nPoints= " << nPoints << "; tolerance= " << tolerance / mm << " mm; verbose: " << verbose << "\n"
44  << " RegionFlag: " << regionFlag << " PVname: " << PVname << " LVname: " << LVname << "\n"
45  << " Nlv= " << numLV << " Npv= " << numPV << G4endl;
46 
47  if (0 < nn) {
48  for (unsigned int ii = 0; ii < nn; ++ii) {
49  if (nodeNames[ii].empty() || "world" == nodeNames[ii] || "World" == nodeNames[ii]) {
50  nodeNames[ii] = "DDDWorld";
51  G4cout << "### Check overlaps for DDDWorld " << G4endl;
52  G4VPhysicalVolume *pv = pvs->GetVolume("DDDWorld");
53  G4GeomTestVolume test(pv, tolerance, nPoints, verbose);
54  test.SetErrorsThreshold(nPrints);
55  test.TestRecursiveOverlap(level, depth);
56  } else if (regionFlag) {
57  G4cout << "---------------------------------------------------------------" << G4endl;
58  G4cout << "### Check overlaps for G4Region Node[" << ii << "] : " << nodeNames[ii] << G4endl;
59  G4Region *reg = regStore->GetRegion((G4String)nodeNames[ii]);
60  if (!reg) {
61  G4cout << "### NO G4Region found - EXIT" << G4endl;
62  return;
63  }
64  std::vector<G4LogicalVolume *>::iterator rootLVItr = reg->GetRootLogicalVolumeIterator();
65  unsigned int numRootLV = reg->GetNumberOfRootVolumes();
66  G4cout << " " << numRootLV << " Root Logical Volumes in this region" << G4endl;
67 
68  for (unsigned int iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
69  // Cover each root logical volume in this region
70  lv = *rootLVItr;
71  G4cout << "### Check overlaps for G4LogicalVolume " << lv->GetName() << G4endl;
72  for (unsigned int i = 0; i < numPV; ++i) {
73  if (((*pvs)[i])->GetLogicalVolume() == lv) {
74  G4String pvname = ((*pvs)[i])->GetName();
75  G4bool isNew = true;
76  for (unsigned int k = 0; k < savedgdml.size(); ++k) {
77  if (pvname == savedgdml[k]) {
78  isNew = false;
79  break;
80  }
81  }
82  if (!isNew) {
83  G4cout << "### Check overlaps for PhysVolume " << pvname << " is skipted because was already done"
84  << G4endl;
85  continue;
86  }
87  savedgdml.push_back(pvname);
88  G4cout << "### Check overlaps for PhysVolume " << pvname << G4endl;
89  // gdml dump only for 1 volume
90  if (gdmlFlag) {
91  G4GDMLParser gdml;
92  gdml.Write(pvname + ".gdml", (*pvs)[i], true);
93  }
94  G4GeomTestVolume test(((*pvs)[i]), tolerance, nPoints, verbose);
95  test.SetErrorsThreshold(nPrints);
96  test.TestRecursiveOverlap(level, depth);
97  }
98  }
99  }
100 
101  } else {
102  G4cout << "### Check overlaps for PhysVolume Node[" << ii << "] : " << nodeNames[ii] << G4endl;
103  G4VPhysicalVolume *pv = pvs->GetVolume((G4String)nodeNames[ii]);
104  G4GeomTestVolume test(pv, tolerance, nPoints, verbose);
105  test.SetErrorsThreshold(nPrints);
106  test.TestRecursiveOverlap(level, depth);
107  }
108  }
109  }
110  if (!PVname.empty()) {
111  G4cout << "----------- List of PhysVolumes by name -----------------" << G4endl;
112  for (unsigned int i = 0; i < numPV; ++i) {
113  if (PVname == ((*pvs)[i])->GetName()) {
114  G4cout << " ##### PhysVolume " << PVname << " [" << ((*pvs)[i])->GetCopyNo()
115  << "] LV: " << ((*pvs)[i])->GetLogicalVolume()->GetName()
116  << " Mother LV: " << ((*pvs)[i])->GetMotherLogical()->GetName()
117  << " Region: " << ((*pvs)[i])->GetLogicalVolume()->GetRegion()->GetName() << G4endl;
118  G4cout << " Translation: " << ((*pvs)[i])->GetObjectTranslation() << G4endl;
119  G4cout << " Rotation: " << ((*pvs)[i])->GetObjectRotationValue() << G4endl;
120  if (gdmlFlag) {
121  G4GDMLParser gdml;
122  gdml.Write(PVname + ".gdml", (*pvs)[i], true);
123  }
124  }
125  }
126  }
127  if (!LVname.empty()) {
128  G4cout << "---------- List of Logical Volumes by name ------------------" << G4endl;
129  for (unsigned int i = 0; i < numLV; ++i) {
130  if (LVname == ((*lvs)[i])->GetName()) {
131  G4int np = ((*lvs)[i])->GetNoDaughters();
132  G4cout << " ##### LogVolume " << LVname << " " << np << " daughters"
133  << " Region: " << ((*lvs)[i])->GetRegion()->GetName() << G4endl;
134  G4cout << *(((*lvs)[i])->GetSolid()) << G4endl;
135  for (G4int j = 0; j < np; ++j) {
136  G4VPhysicalVolume *pv = ((*lvs)[i])->GetDaughter(j);
137  if (pv) {
138  G4cout << " PV: " << pv->GetName() << " [" << pv->GetCopyNo() << "]"
139  << " type: " << pv->VolumeType() << " multiplicity: " << pv->GetMultiplicity()
140  << " LV: " << pv->GetLogicalVolume()->GetName() << G4endl;
141  G4cout << " Translation: " << pv->GetObjectTranslation() << G4endl;
142  G4cout << " Rotation: " << pv->GetObjectRotationValue() << G4endl;
143  G4cout << *(pv->GetLogicalVolume()->GetSolid()) << G4endl;
144  }
145  }
146  }
147  }
148  }
149  G4cout << "---------------- End of overlap checks ---------------------" << G4endl;
150 }
const double tolerance
int np
Definition: AMPTWrapper.h:33
def pv(vc)
Definition: MetAnalyzer.py:7
ii
Definition: cuy.py:590
int k[5][pyjets_maxn]
G4CheckOverlap::~G4CheckOverlap ( )

Definition at line 152 of file G4CheckOverlap.cc.

152 {}