CMS 3D CMS Logo

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

#include <PrintGeomSummary.h>

Inheritance diagram for PrintGeomSummary:
SimWatcher Observer< const BeginOfJob * > Observer< const BeginOfRun * >

Public Member Functions

 PrintGeomSummary (edm::ParameterSet const &p)
 
 ~PrintGeomSummary () override
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 

Private Member Functions

void addName (std::string name)
 
void addSolid (const DDLogicalPart &part)
 
void dumpSummary (std::ostream &out, std::string name)
 
void fillLV (G4LogicalVolume *lv)
 
G4VPhysicalVolume * getTopPV ()
 
void printSummary (std::ostream &out)
 
void update (const BeginOfJob *job) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

std::map< DDSolidShape, std::pair< int, int > > kount_
 
std::vector< G4LogicalVolume * > lvs_
 
std::vector< std::string > nodeNames_
 
std::vector< G4VSolid * > sls_
 
std::map< std::string, DDSolidShapesolidMap_
 
std::map< DDSolidShape, std::string > solidShape_
 
G4VPhysicalVolume * theTopPV_
 
std::vector< G4LogicalVolume * > touch_
 

Additional Inherited Members

Detailed Description

Definition at line 24 of file PrintGeomSummary.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file PrintGeomSummary.cc.

References dd_not_init, ddbox, ddcons, ddcuttubs, ddellipticaltube, ddextrudedpolygon, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddshapeless, ddsphere, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, edm::ParameterSet::getUntrackedParameter(), cuy::ii, nodeNames_, and solidShape_.

32  : theTopPV_(nullptr) {
33  std::vector<std::string> defNames;
34  nodeNames_ = p.getUntrackedParameter<std::vector<std::string>>("NodeNames", defNames);
35  G4cout << "PrintGeomSummary:: initialised for " << nodeNames_.size() << " nodes:" << G4endl;
36  for (unsigned int ii = 0; ii < nodeNames_.size(); ii++)
37  G4cout << "Node[" << ii << "] : " << nodeNames_[ii] << G4endl;
38 
41  solidShape_[DDSolidShape::ddtrap] = "Trapezoid";
44  solidShape_[DDSolidShape::ddpolyhedra_rz] = "Polyhedra_rz";
45  solidShape_[DDSolidShape::ddpolycone_rrz] = "Polycone_rrz";
46  solidShape_[DDSolidShape::ddpolyhedra_rrz] = "Polyhedra_rrz";
48  solidShape_[DDSolidShape::ddunion] = "UnionSolid";
49  solidShape_[DDSolidShape::ddsubtraction] = "SubtractionSolid";
50  solidShape_[DDSolidShape::ddintersection] = "IntersectionSolid";
51  solidShape_[DDSolidShape::ddshapeless] = "ShapelessSolid";
52  solidShape_[DDSolidShape::ddpseudotrap] = "PseudoTrapezoid";
53  solidShape_[DDSolidShape::ddtrunctubs] = "TruncatedTube";
55  solidShape_[DDSolidShape::ddellipticaltube] = "EllipticalTube";
57  solidShape_[DDSolidShape::ddextrudedpolygon] = "ExtrudedPolygon";
59 }
std::map< DDSolidShape, std::string > solidShape_
G4VPhysicalVolume * theTopPV_
std::vector< std::string > nodeNames_
ii
Definition: cuy.py:590
PrintGeomSummary::~PrintGeomSummary ( )
override

Definition at line 61 of file PrintGeomSummary.cc.

61 {}

Member Function Documentation

void PrintGeomSummary::addName ( std::string  name)
private

Definition at line 174 of file PrintGeomSummary.cc.

References dd_not_init, plotBeamSpotDB::first, kount_, genParticles_cff::map, truncPyr::refl(), edm::second(), and solidMap_.

Referenced by dumpSummary().

174  {
175  bool refl(false);
176  if (name.find("_refl") < name.size()) {
177  refl = true;
178  name = name.substr(0, (name.find("_refl")));
179  }
180  std::map<std::string, DDSolidShape>::const_iterator jt = solidMap_.find(name);
181  DDSolidShape shape = (jt == solidMap_.end()) ? DDSolidShape::dd_not_init : jt->second;
182  std::map<DDSolidShape, std::pair<int, int>>::iterator itr = kount_.find(shape);
183  if (itr == kount_.end()) {
184  kount_[shape] = (refl) ? std::pair<int, int>(0, 1) : std::pair<int, int>(1, 0);
185  } else {
186  kount_[shape] = (refl) ? std::pair<int, int>(((itr->second).first), ++((itr->second).second))
187  : std::pair<int, int>(++((itr->second).first), ((itr->second).second));
188  }
189 }
DDSolidShape
Definition: DDSolidShapes.h:6
U second(std::pair< T, U > const &p)
Pt3D refl(const Pt3D &p)
std::map< std::string, DDSolidShape > solidMap_
std::map< DDSolidShape, std::pair< int, int > > kount_
void PrintGeomSummary::addSolid ( const DDLogicalPart part)
private

Definition at line 90 of file PrintGeomSummary.cc.

References dd_not_init, DDName::name(), dataset::name, DDBase< N, C >::name(), DDSolid::shape(), DDLogicalPart::solid(), solidMap_, solidShape_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by update().

90  {
91  const DDSolid& solid = part.solid();
92  std::map<DDSolidShape, std::string>::iterator it = solidShape_.find(solid.shape());
93  std::string name = solid.name().name();
94  if (it == solidShape_.end())
96  else
97  solidMap_[name] = it->first;
98  //G4cout << "Solid " << name << " is of shape " << solidMap_[name] << G4endl;
99 }
const N & name() const
Definition: DDBase.h:74
std::map< DDSolidShape, std::string > solidShape_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
std::map< std::string, DDSolidShape > solidMap_
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
void PrintGeomSummary::dumpSummary ( std::ostream &  out,
std::string  name 
)
private

Definition at line 138 of file PrintGeomSummary.cc.

References addName(), kount_, lvs_, printSummary(), sls_, AlCaHLTBitMon_QueryRunRegistry::string, and touch_.

Referenced by update().

138  {
139  //---------- Dump number of objects of each class
140  out << G4endl << G4endl << "@@@@@@@@@@@@@@@@@@ Dumping Summary For Node " << name << G4endl;
141  out << " Number of G4VSolid's: " << sls_.size() << G4endl;
142  out << " Number of G4LogicalVolume's: " << lvs_.size() << G4endl;
143  out << " Number of Touchable's: " << touch_.size() << G4endl;
144  //First the solids
145  out << G4endl << "Occurence of each type of shape among Solids" << G4endl;
146  kount_.clear();
147  for (std::vector<G4VSolid*>::iterator it = sls_.begin(); it != sls_.end(); ++it) {
148  std::string name = (*it)->GetName();
149  addName(name);
150  }
151  printSummary(out);
152  //Then the logical volumes
153  out << G4endl << "Occurence of each type of shape among Logical Volumes" << G4endl;
154  kount_.clear();
155  for (std::vector<G4LogicalVolume*>::iterator it = lvs_.begin(); it != lvs_.end(); ++it) {
156  std::string name = ((*it)->GetSolid())->GetName();
157  addName(name);
158  }
159  printSummary(out);
160  //Finally the touchables
161  out << G4endl << "Occurence of each type of shape among Touchables" << G4endl;
162  kount_.clear();
163  for (std::vector<G4LogicalVolume*>::iterator it = touch_.begin(); it != touch_.end(); ++it) {
164  std::string name = ((*it)->GetSolid())->GetName();
165  addName(name);
166  }
167  printSummary(out);
168 }
std::vector< G4VSolid * > sls_
void addName(std::string name)
void printSummary(std::ostream &out)
std::vector< G4LogicalVolume * > lvs_
std::vector< G4LogicalVolume * > touch_
std::map< DDSolidShape, std::pair< int, int > > kount_
void PrintGeomSummary::fillLV ( G4LogicalVolume *  lv)
private

Definition at line 127 of file PrintGeomSummary.cc.

References spr::find(), cuy::ii, createfilelist::int, lvs_, sls_, and touch_.

Referenced by update().

127  {
128  if (std::find(lvs_.begin(), lvs_.end(), lv) == lvs_.end())
129  lvs_.push_back(lv);
130  G4VSolid* sl = lv->GetSolid();
131  if (std::find(sls_.begin(), sls_.end(), sl) == sls_.end())
132  sls_.push_back(sl);
133  touch_.push_back(lv);
134  for (int ii = 0; ii < (int)(lv->GetNoDaughters()); ii++)
135  fillLV(lv->GetDaughter(ii)->GetLogicalVolume());
136 }
std::vector< G4VSolid * > sls_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void fillLV(G4LogicalVolume *lv)
ii
Definition: cuy.py:590
std::vector< G4LogicalVolume * > lvs_
std::vector< G4LogicalVolume * > touch_
G4VPhysicalVolume * PrintGeomSummary::getTopPV ( )
private

Definition at line 170 of file PrintGeomSummary.cc.

Referenced by update().

170  {
171  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
172 }
void PrintGeomSummary::printSummary ( std::ostream &  out)
private

Definition at line 191 of file PrintGeomSummary.cc.

References plotBeamSpotDB::first, gen::k, kount_, genParticles_cff::map, solidShape_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dumpSummary().

191  {
192  int k(0);
193  for (std::map<DDSolidShape, std::pair<int, int>>::iterator itr = kount_.begin(); itr != kount_.end(); ++itr, ++k) {
194  std::string shape = solidShape_[itr->first];
195  out << "Shape [" << k << "] " << shape << " # " << (itr->second).first << " : " << (itr->second).second << G4endl;
196  }
197 }
std::map< DDSolidShape, std::string > solidShape_
DDSolidShape
Definition: DDSolidShapes.h:6
int k[5][pyjets_maxn]
std::map< DDSolidShape, std::pair< int, int > > kount_
void PrintGeomSummary::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 63 of file PrintGeomSummary.cc.

References addSolid(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, DDCompactView::graph(), mps_fire::i, and solidMap_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

63  {
65  (*job)()->get<IdealGeometryRecord>().get(pDD);
66  const DDCompactView* cpv = &(*pDD);
67 
68  const auto& gra = cpv->graph();
69 
72 
73  Graph::index_type i = 0;
74  solidMap_.clear();
75  for (adjl_iterator git = gra.begin(); git != gra.end(); ++git) {
76  const DDLogicalPart& ddLP = gra.nodeData(git);
77  addSolid(ddLP);
78  ++i;
79  if (!git->empty()) {
80  // ask for children of ddLP
81  for (Graph::edge_list::const_iterator cit = git->begin(); cit != git->end(); ++cit) {
82  const DDLogicalPart& ddcurLP = gra.nodeData(cit->first);
83  addSolid(ddcurLP);
84  }
85  }
86  }
87  G4cout << "Finds " << solidMap_.size() << " different solids in the tree" << G4endl;
88 }
std::vector< double >::size_type index_type
Definition: Graph.h:16
void addSolid(const DDLogicalPart &part)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
Graph::const_adj_iterator adjl_iterator
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:83
adj_list::const_iterator const_adj_iterator
Definition: Graph.h:125
std::map< std::string, DDSolidShape > solidMap_
void PrintGeomSummary::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 101 of file PrintGeomSummary.cc.

References dumpSummary(), fillLV(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getTopPV(), gen::k, lvs_, dataset::name, nodeNames_, sls_, AlCaHLTBitMon_QueryRunRegistry::string, theTopPV_, and touch_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

101  {
102  theTopPV_ = getTopPV();
103  if (theTopPV_) {
104  lvs_.clear();
105  sls_.clear();
106  touch_.clear();
107  fillLV(theTopPV_->GetLogicalVolume());
108  std::string name = theTopPV_->GetName();
109  dumpSummary(G4cout, name);
110 
111  for (unsigned int k = 0; k < nodeNames_.size(); ++k) {
112  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
113  std::vector<G4LogicalVolume*>::const_iterator lvcite;
114  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
115  if ((*lvcite)->GetName() == (G4String)(nodeNames_[k])) {
116  lvs_.clear();
117  sls_.clear();
118  touch_.clear();
119  fillLV(*lvcite);
121  }
122  }
123  }
124  }
125 }
std::vector< G4VSolid * > sls_
G4VPhysicalVolume * getTopPV()
G4VPhysicalVolume * theTopPV_
std::vector< std::string > nodeNames_
void fillLV(G4LogicalVolume *lv)
int k[5][pyjets_maxn]
void dumpSummary(std::ostream &out, std::string name)
std::vector< G4LogicalVolume * > lvs_
std::vector< G4LogicalVolume * > touch_

Member Data Documentation

std::map<DDSolidShape, std::pair<int, int> > PrintGeomSummary::kount_
private

Definition at line 46 of file PrintGeomSummary.h.

Referenced by addName(), dumpSummary(), and printSummary().

std::vector<G4LogicalVolume *> PrintGeomSummary::lvs_
private

Definition at line 44 of file PrintGeomSummary.h.

Referenced by dumpSummary(), fillLV(), and update().

std::vector<std::string> PrintGeomSummary::nodeNames_
private

Definition at line 40 of file PrintGeomSummary.h.

Referenced by PrintGeomSummary(), and update().

std::vector<G4VSolid *> PrintGeomSummary::sls_
private

Definition at line 45 of file PrintGeomSummary.h.

Referenced by dumpSummary(), fillLV(), and update().

std::map<std::string, DDSolidShape> PrintGeomSummary::solidMap_
private

Definition at line 42 of file PrintGeomSummary.h.

Referenced by addName(), addSolid(), and update().

std::map<DDSolidShape, std::string> PrintGeomSummary::solidShape_
private

Definition at line 41 of file PrintGeomSummary.h.

Referenced by addSolid(), PrintGeomSummary(), and printSummary().

G4VPhysicalVolume* PrintGeomSummary::theTopPV_
private

Definition at line 43 of file PrintGeomSummary.h.

Referenced by update().

std::vector<G4LogicalVolume *> PrintGeomSummary::touch_
private

Definition at line 44 of file PrintGeomSummary.h.

Referenced by dumpSummary(), fillLV(), and update().