18 #include "G4PhysicalVolumeStore.hh"
19 #include "G4LogicalVolumeStore.hh"
20 #include "G4VPhysicalVolume.hh"
21 #include "G4LogicalVolume.hh"
22 #include "G4VSolid.hh"
23 #include "G4Material.hh"
25 #include "G4VisAttributes.hh"
26 #include "G4UserLimits.hh"
27 #include "G4TransportationManager.hh"
32 using namespace CLHEP;
45 _maxLevelsCounted = 50;
46 _countsPerLevel.assign(_maxLevelsCounted,0);
58 nchar = name.find(
"*");
59 name.assign(name,0,nchar);
61 std::cout <<
"size of _lvNames2Dump = " << _lvNames2Dump.size()
62 <<
" size of _radiusLayer = " << _radiusLayer.size()
63 <<
" size of _zLayer = " << _zLayer.size() << std::endl;
64 std::cout <<
"PrintGeomMatInfo:: initialised with verbosity levels:"
65 <<
" Summary " << _dumpSummary <<
" LVTree " << _dumpLVTree
66 <<
" LVList " << _dumpLVList <<
" Material " << _dumpMaterial
68 <<
" LVMatBudget " << _dumpLVMatBudget <<
" for";
69 _areaLayer.reserve(_lvNames2Dump.size());
70 if(_lvNames2Dump.size() == _radiusLayer.size() &&
71 _lvNames2Dump.size() == _zLayer.size()) {
72 for (
unsigned int i=0;
i<_lvNames2Dump.size();
i++) {
73 _areaLayer[
i] = 2.0*3.14159*_radiusLayer[
i]*_zLayer[
i];
75 <<
" " << _lvNames2Dump[
i] <<
" radius = " << _radiusLayer[
i]
76 <<
" z = " << _zLayer[
i] <<
" area = " << _areaLayer[
i];
79 _areaLayer.assign(3,0.0);
81 <<
" Problem with unequal sizes!! Fix and rerun";
84 <<
" and max levels for count = " << _maxLevelsCounted;
86 <<
" LV " << _dumpLV <<
" Solid " << _dumpSolid
87 <<
" Attribs " << _dumpAtts
89 <<
" PV " << _dumpPV <<
" Rotation " << _dumpRotation
90 <<
" Replica " << _dumpReplica
92 <<
" Touchable " << _dumpTouch <<
" for names (0-" << nchar
95 <<
" Sensitive " << _dumpSense <<
" for " <<
names.size()
107 (*job)()->get<IdealGeometryRecord>().get(pDD);
109 std::cout <<
"PrintGeomMatInfo::Get Printout of Sensitive Volumes "
110 <<
"for " <<
names.size() <<
" Readout Units" << std::endl;
111 for (
unsigned int i=0;
i<
names.size();
i++) {
118 std::cout <<
"PrintGeomMatInfo:: Get Filtered view for "
119 << attribute <<
" = " << sd << std::endl;
131 unsigned int leafDepth = copy.size();
132 std::cout << leafDepth << spaces <<
"### VOLUME = " << lvname
134 for (
int k=leafDepth-1;
k>=0;
k--)
std::cout <<
" " << copy[
k];
135 std::cout <<
" Centre at " << tran <<
" (r = " << tran.Rho()
136 <<
", phi = " << tran.phi()/deg <<
")" << std::endl;
145 theTopPV = getTopPV();
147 if (_dumpSummary) dumpSummary(
std::cout);
148 if (_dumpLVTree) dumpG4LVTree(
std::cout);
149 if (_dumpLVMatBudget) dumpG4LVMatBudget(
std::cout);
152 if (_dumpMaterial) dumpMaterialList(
std::cout);
153 if (_dumpLVList) dumpG4LVList(
std::cout);
156 if (_dumpLV || _dumpPV || _dumpTouch) dumpHierarchyTreePVLV(
std::cout);
162 out <<
" @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << std::endl;
165 out <<
" No volume created " << std::endl;
168 out <<
" @@@ Geometry built inside world volume: " << theTopPV->GetName() << std::endl;
170 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
171 std::vector<G4LogicalVolume *>::const_iterator lvcite;
172 std::set<G4VSolid *> theSolids;
173 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
174 theSolids.insert((*lvcite)->GetSolid());
175 out <<
" Number of G4VSolid's: " << theSolids.size() << std::endl;
176 out <<
" Number of G4LogicalVolume's: " << lvs->size() << std::endl;
177 const G4PhysicalVolumeStore * pvs = G4PhysicalVolumeStore::GetInstance();
178 out <<
" Number of G4VPhysicalVolume's: " << pvs->size() << std::endl;
179 out <<
" Number of Touchable's: " << countNoTouchables() << std::endl;
180 const G4MaterialTable * matTab = G4Material::GetMaterialTable();
181 out <<
" Number of G4Material's: " << matTab->size() << std::endl;
186 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's List " << std::endl;
187 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
188 std::vector<G4LogicalVolume*>::const_iterator lvcite;
189 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
190 out <<
"LV:" << (*lvcite)->GetName() <<
"\tMaterial: " << (*lvcite)->GetMaterial()->GetName() << std::endl;
195 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree " << std::endl;
196 G4LogicalVolume * lv = getTopLV();
197 dumpG4LVLeaf(lv,0,1,out);
202 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4Material List ";
203 const G4MaterialTable * matTab = G4Material::GetMaterialTable();
204 out <<
" with " << matTab->size() <<
" materials " << std::endl;
205 std::vector<G4Material*>::const_iterator matite;
206 for (matite = matTab->begin(); matite != matTab->end(); matite++)
207 out <<
"Material: " << (*matite) << std::endl;
212 for (
unsigned int ii=0;
ii < leafDepth;
ii++) out <<
" ";
213 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" << count
216 std::map<G4LogicalVolume*, unsigned int> lvCount;
217 std::map<G4LogicalVolume*, unsigned int>::const_iterator cite;
218 for (
int ii = 0;
ii < lv->GetNoDaughters();
ii++) {
219 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
220 if (cite != lvCount.end()) lvCount[cite->first] = (cite->second) + 1;
221 else lvCount.insert(std::pair< G4LogicalVolume*,unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(),1));
223 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
224 dumpG4LVLeaf((cite->first), leafDepth+1, (cite->second), out);
229 out <<
" @@@@@@@@@@@@@@@@ DUMPING G4LogicalVolume's Material Budget Tree " << std::endl;
230 G4LogicalVolume * lv = getTopLV();
231 dumpG4LVLeafWithMat(lv,0,1,out);
237 if(_dumpIt && _level2Dump == leafDepth) {
242 for (
unsigned int i=0;
i<_lvNames2Dump.size();
i++) {
243 if(_lvNames2Dump[
i].
compare(lv->GetName()) == 0) {
246 _level2Dump = leafDepth;
253 if(leafDepth < _maxLevelsCounted) _countsPerLevel[leafDepth] =
count;
254 unsigned int total_multipler = 1;
255 for (
unsigned int ii=_level2Dump;
ii <= leafDepth;
ii++) total_multipler *= _countsPerLevel[
ii];
256 double thick = (lv->GetSolid()->GetCubicVolume() * total_multipler)/_areaLayer[_dumpIndex];
257 for (
unsigned int ii=0;
ii < leafDepth;
ii++) out <<
" ";
261 out <<
" LV::" << leafDepth <<
": " << lv->GetName() <<
" :" << count
262 <<
": " << lv->GetSolid()->GetName() <<
" :" << lv->GetSolid()->GetCubicVolume()
263 <<
": "<< lv->GetMaterial()->GetName() <<
" :" << lv->GetMaterial()->GetRadlen()
264 <<
":" <<
" :" << total_multipler <<
":"
265 <<
" thk :" << thick <<
": x/X0 :" << thick/lv->GetMaterial()->GetRadlen()
266 <<
":" <<
" Kg : " << lv->GetMass()/kg << std::endl;
268 for (
unsigned int ii=0;
ii < leafDepth;
ii++) out <<
" ";
269 out <<
" LV:(" << leafDepth <<
") " << lv->GetName() <<
" (" << count <<
")" << std::endl;
273 std::map<G4LogicalVolume*, unsigned int> lvCount;
274 std::map<G4LogicalVolume*, unsigned int>::const_iterator cite;
275 for (
int ii = 0;
ii < lv->GetNoDaughters();
ii++) {
276 cite = lvCount.find(lv->GetDaughter(
ii)->GetLogicalVolume());
277 if (cite != lvCount.end()) lvCount[cite->first] = (cite->second) + 1;
278 else lvCount.insert(std::pair< G4LogicalVolume*,unsigned int>(lv->GetDaughter(
ii)->GetLogicalVolume(),1));
280 for (cite = lvCount.begin(); cite != lvCount.end(); cite++)
281 dumpG4LVLeafWithMat((cite->first), leafDepth+1, (cite->second), out);
288 G4LogicalVolume * lv = getTopLV();
289 add1touchable(lv, nTouch);
296 int siz = lv->GetNoDaughters();
297 for(
int ii = 0;
ii < siz;
ii++)
298 add1touchable(lv->GetDaughter(
ii)->GetLogicalVolume(), ++nTouch);
309 G4LogicalVolume* topLV = getTopLV();
312 dumpHierarchyLeafPVLV(topLV, 0, out);
313 dumpPV(theTopPV, 0, out);
316 if (_dumpTouch) dumpTouch(theTopPV, 0, out);
322 dumpLV(lv, leafDepth, out);
326 std::set< G4LogicalVolume * > lvDaughters;
327 int NoDaughters = lv->GetNoDaughters();
328 while ((NoDaughters--)>0)
330 G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
332 lvDaughters.insert(pvD->GetLogicalVolume());
335 std::set< G4LogicalVolume * >::const_iterator scite;
336 mmlvpv::const_iterator mmcite;
339 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++)
341 std::pair< mmlvpv::iterator, mmlvpv::iterator > mmER = lvpvDaughters.equal_range(*scite);
343 for (mmcite = mmER.first ; mmcite != mmER.second; mmcite++)
344 dumpPV((*mmcite).second, leafDepth+1, out);
346 dumpHierarchyLeafPVLV(*scite, leafDepth+1, out );
352 std::string spaces = spacesFromLeafDepth(leafDepth);
356 out << leafDepth << spaces <<
"$$$ VOLUME = " << lv->GetName()
357 <<
" Solid: " << lv->GetSolid()->GetName() <<
" MATERIAL: "
358 << lv->GetMaterial()->GetName() << std::endl;
360 dumpSolid(lv->GetSolid(), leafDepth,
out);
366 const G4VisAttributes * fVA = lv->GetVisAttributes();
368 out << spaces <<
" VISUALISATION ATTRIBUTES: " << std::endl;
369 out << spaces <<
" IsVisible " << fVA->IsVisible() << std::endl;
370 out << spaces <<
" IsDaughtersInvisible " << fVA->IsDaughtersInvisible() << std::endl;
371 out << spaces <<
" Colour " << fVA->GetColour() << std::endl;
372 out << spaces <<
" LineStyle " << fVA->GetLineStyle() << std::endl;
373 out << spaces <<
" LineWidth " << fVA->GetLineWidth() << std::endl;
374 out << spaces <<
" IsForceDrawingStyle " << fVA->IsForceDrawingStyle() << std::endl;
375 out << spaces <<
" ForcedDrawingStyle " << fVA->GetForcedDrawingStyle() << std::endl;
379 G4UserLimits * fUL = lv->GetUserLimits();
382 out << spaces <<
" MaxAllowedStep " << fUL->GetMaxAllowedStep(dummy) << std::endl;
383 out << spaces <<
" UserMaxTrackLength " << fUL->GetUserMaxTrackLength(dummy) << std::endl;
384 out << spaces <<
" UserMaxTime " << fUL->GetUserMaxTime(dummy) << std::endl;
385 out << spaces <<
" UserMinEkine " << fUL->GetUserMinEkine(dummy) << std::endl;
386 out << spaces <<
" UserMinRange " << fUL->GetUserMinRange(dummy) << std::endl;
390 if (lv->GetSensitiveDetector())
391 out << spaces <<
" IS SENSITIVE DETECTOR " << std::endl;
392 if (lv->GetFieldManager())
393 out << spaces <<
" FIELD ON " << std::endl;
397 <<
" Quality for optimisation, average number of voxels to be spent per content "
398 << lv->GetSmartless() << std::endl;
401 if (lv->GetFastSimulationManager())
402 out << spaces <<
" Logical Volume is an envelope for a FastSimulationManager "
404 out << spaces <<
" Weight used in the event biasing technique = "
405 << lv->GetBiasWeight() << std::endl;
412 std::string spaces = spacesFromLeafDepth(leafDepth);
418 if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
419 out << leafDepth << spaces <<
"### VOLUME = " << pv->GetName()
420 <<
" Copy No " << pv->GetCopyNo() <<
" in " << mother
421 <<
" at " << pv->GetTranslation();
423 if (!pv->IsReplicated())
427 if(pv->GetRotation() == 0) out <<
" with no rotation" << std::endl;
428 else if(!_dumpRotation) out <<
" with rotation" << std::endl;
429 else out <<
" with rotation " << *(pv->GetRotation()) << std::endl;
436 out << spaces <<
" It is replica: " << std::endl;
442 pv->GetReplicationData(axis, nReplicas, width, offset, consuming);
443 out << spaces <<
" axis " << axis << std::endl
444 << spaces <<
" nReplicas " << nReplicas << std::endl;
445 if (pv->GetParameterisation() != 0)
446 out << spaces <<
" It is parameterisation " << std::endl;
448 out << spaces <<
" width " << width << std::endl
449 << spaces <<
" offset " << offset << std::endl
450 << spaces <<
" consuming" << consuming << std::endl;
451 if (pv->GetParameterisation() != 0)
452 out << spaces <<
" It is parameterisation " << std::endl;
459 std::string spaces = spacesFromLeafDepth(leafDepth);
460 if (leafDepth == 0) fHistory.SetFirstEntry(pv);
461 else fHistory.NewLevel(pv, kNormal, pv->GetCopyNo());
463 G4ThreeVector globalpoint = fHistory.GetTopTransform().Inverse().
464 TransformPoint(G4ThreeVector(0,0,0));
465 G4LogicalVolume * lv = pv->GetLogicalVolume();
468 if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
470 lvname.assign(lvname,0,nchar);
472 out << leafDepth << spaces <<
"### VOLUME = " << lv->GetName()
473 <<
" Copy No " << pv->GetCopyNo() <<
" in " << mother
474 <<
" global position of centre " << globalpoint <<
" (r = "
475 << globalpoint.perp() <<
", phi = " << globalpoint.phi()/deg
478 int NoDaughters = lv->GetNoDaughters();
479 while ((NoDaughters--)>0)
481 G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
482 if (!pvD->IsReplicated()) dumpTouch(pvD, leafDepth+1, out);
485 if (leafDepth > 0) fHistory.BackLevel();
492 for(ii = 0; ii < leafDepth; ii++) { spaces +=
" "; }
498 std::string spaces = spacesFromLeafDepth(leafDepth);
499 out << spaces << *(sol) << std::endl;
504 return G4TransportationManager::GetTransportationManager()
505 ->GetNavigatorForTracking()->GetWorldVolume();
509 {
return theTopPV->GetLogicalVolume(); }
T getUntrackedParameter(std::string const &, T const &) const
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
G4VPhysicalVolume * getTopPV()
void dumpG4LVTree(std::ostream &out=std::cout)
void addFilter(const DDFilter &, log_op op=AND)
static const HistoName names[]
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
void dumpG4LVLeafWithMat(G4LogicalVolume *lv, unsigned int leafDepth, unsigned int count, std::ostream &out=std::cout)
nav_type copyNumbers() const
return the stack of copy numbers
void dumpMaterialList(std::ostream &out=std::cout)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
void add1touchable(G4LogicalVolume *lv, int &nTouch)
void dumpHierarchyLeafPVLV(G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &out=std::cout)
void dumpG4LVList(std::ostream &out=std::cout)
void dumpG4LVMatBudget(std::ostream &out=std::cout)
void dumpHierarchyTreePVLV(std::ostream &out=std::cout)
void dumpLV(G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &out=std::cout)
bool next()
set current node to the next node in the filtered tree
std::string spacesFromLeafDepth(unsigned int leafDepth)
void dumpPV(G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=std::cout)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=std::cout)
Container::value_type value_type
void dumpSummary(std::ostream &out=std::cout)
G4LogicalVolume * getTopLV()
PrintGeomMatInfo(edm::ParameterSet const &p)
void update(const BeginOfJob *job)
This routine will be called when the appropriate signal arrives.
void dumpSolid(G4VSolid *sol, unsigned int leafDepth, std::ostream &out=std::cout)
bool firstChild()
set the current node to the first child ...
void dumpG4LVLeaf(G4LogicalVolume *lv, unsigned int leafDepth, unsigned int count, std::ostream &out=std::cout)
void setCriteria(const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
const DDTranslation & translation() const
The absolute translation of the current node.
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.