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, ddellipsoid, ddellipticaltube, ddextrudedpolygon, ddintersection, ddorb, ddparallelepiped, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, 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()
36  << " nodes:" << G4endl;
37  for (unsigned int ii=0; ii<nodeNames_.size(); ii++)
38  G4cout << "Node[" << ii << "] : " << nodeNames_[ii] << G4endl;
39 
40  solidShape_[ddbox] = "Box";
41  solidShape_[ddtubs] = "Tube";
42  solidShape_[ddtrap] = "Trapezoid";
43  solidShape_[ddcons] = "Cone";
44  solidShape_[ddpolycone_rz] = "Polycone_rz";
45  solidShape_[ddpolyhedra_rz] = "Polyhedra_rz";
46  solidShape_[ddpolycone_rrz] = "Polycone_rrz";
47  solidShape_[ddpolyhedra_rrz] = "Polyhedra_rrz";
48  solidShape_[ddtorus] = "Torus";
49  solidShape_[ddunion] = "UnionSolid";
50  solidShape_[ddsubtraction] = "SubtractionSolid";
51  solidShape_[ddintersection] = "IntersectionSolid";
52  solidShape_[ddreflected] = "ReflectedSolid";
53  solidShape_[ddshapeless] = "ShapelessSolid";
54  solidShape_[ddpseudotrap] = "PseudoTrapezoid";
55  solidShape_[ddtrunctubs] = "TruncatedTube";
56  solidShape_[ddsphere] = "Sphere";
57  solidShape_[ddorb] = "Orb";
58  solidShape_[ddellipticaltube] = "EllipticalTube";
59  solidShape_[ddellipsoid] = "Ellipsoid";
60  solidShape_[ddparallelepiped] = "Parallelepiped";
61  solidShape_[ddcuttubs] = "CutTubs";
62  solidShape_[ddextrudedpolygon]= "ExtrudedPolygon";
63  solidShape_[dd_not_init] = "Unknown";
64 }
std::map< DDSolidShape, std::string > solidShape_
G4VPhysicalVolume * theTopPV_
std::vector< std::string > nodeNames_
ii
Definition: cuy.py:588
PrintGeomSummary::~PrintGeomSummary ( )
override

Definition at line 66 of file PrintGeomSummary.cc.

66 {}

Member Function Documentation

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

Definition at line 179 of file PrintGeomSummary.cc.

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

Referenced by dumpSummary().

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

Definition at line 95 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().

95  {
96  const DDSolid& solid = part.solid();
97  std::map<DDSolidShape,std::string>::iterator it = solidShape_.find(solid.shape());
98  std::string name = solid.name().name();
99  if (it == solidShape_.end()) solidMap_[name] = dd_not_init;
100  else solidMap_[name] = it->first;
101 //G4cout << "Solid " << name << " is of shape " << solidMap_[name] << G4endl;
102 }
std::map< DDSolidShape, std::string > solidShape_
const N & name() const
Definition: DDBase.h:78
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:38
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
std::map< std::string, DDSolidShape > solidMap_
void PrintGeomSummary::dumpSummary ( std::ostream &  out,
std::string  name 
)
private

Definition at line 136 of file PrintGeomSummary.cc.

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

Referenced by update().

136  {
137 
138  //---------- Dump number of objects of each class
139  out << G4endl << G4endl
140  << "@@@@@@@@@@@@@@@@@@ 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"
154  << G4endl;
155  kount_.clear();
156  for (std::vector<G4LogicalVolume*>::iterator it = lvs_.begin();
157  it != lvs_.end(); ++it) {
158  std::string name = ((*it)->GetSolid())->GetName();
159  addName(name);
160  }
161  printSummary(out);
162  //Finally the touchables
163  out << G4endl << "Occurence of each type of shape among Touchables"
164  << G4endl;
165  kount_.clear();
166  for (std::vector<G4LogicalVolume*>::iterator it = touch_.begin();
167  it != touch_.end(); ++it) {
168  std::string name = ((*it)->GetSolid())->GetName();
169  addName(name);
170  }
171  printSummary(out);
172 }
void addName(std::string name)
void printSummary(std::ostream &out)
std::vector< G4LogicalVolume * > touch_
std::map< DDSolidShape, std::pair< int, int > > kount_
std::vector< G4VSolid * > sls_
std::vector< G4LogicalVolume * > lvs_
void PrintGeomSummary::fillLV ( G4LogicalVolume *  lv)
private

Definition at line 126 of file PrintGeomSummary.cc.

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

Referenced by update().

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

Definition at line 174 of file PrintGeomSummary.cc.

Referenced by update().

174  {
175 
176  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
177 }
void PrintGeomSummary::printSummary ( std::ostream &  out)
private

Definition at line 197 of file PrintGeomSummary.cc.

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

Referenced by dumpSummary().

197  {
198  int k(0);
199  for (std::map<DDSolidShape,std::pair<int,int> >::iterator itr=kount_.begin();
200  itr != kount_.end(); ++itr, ++k) {
201  std::string shape = solidShape_[itr->first];
202  out << "Shape [" << k << "] " << shape << " # " << (itr->second).first
203  << " : " << (itr->second).second << G4endl;
204  }
205 }
std::map< DDSolidShape, std::string > solidShape_
DDSolidShape
Definition: DDSolidShapes.h:6
std::map< DDSolidShape, std::pair< int, int > > kount_
int k[5][pyjets_maxn]
void PrintGeomSummary::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 68 of file PrintGeomSummary.cc.

References addSolid(), math::Graph< N, E >::begin(), math::Graph< N, E >::end(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, DDCompactView::graph(), mps_fire::i, math::Graph< N, E >::nodeData(), 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().

68  {
69 
71  (*job)()->get<IdealGeometryRecord>().get(pDD);
72  const DDCompactView* cpv = &(*pDD);
73 
74  const DDCompactView::graph_type & gra = cpv->graph();
76  solidMap_.clear();
78  git != gra.end(); ++git) {
79  const DDLogicalPart & ddLP = gra.nodeData(git);
80  addSolid(ddLP);
81  ++i;
82  if (!git->empty()) {
83  // ask for children of ddLP
84  for (DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
85  cit != git->end(); ++cit) {
86  const DDLogicalPart & ddcurLP = gra.nodeData(cit->first);
87  addSolid(ddcurLP);
88  }
89  }
90  }
91  G4cout << "Finds " << solidMap_.size() << " different solids in the tree"
92  << G4endl;
93 }
std::vector< double >::size_type index_type
Definition: Graph.h:16
void addSolid(const DDLogicalPart &part)
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
type of data representation of DDCompactView
Definition: DDCompactView.h:90
const N & nodeData(const edge_type &) const
Definition: Graph.h:312
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
adj_iterator end()
Definition: Graph.h:194
adj_iterator begin()
Definition: Graph.h:192
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 104 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().

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

Member Data Documentation

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

Definition at line 49 of file PrintGeomSummary.h.

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

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

Definition at line 47 of file PrintGeomSummary.h.

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

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

Definition at line 43 of file PrintGeomSummary.h.

Referenced by PrintGeomSummary(), and update().

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

Definition at line 48 of file PrintGeomSummary.h.

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

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

Definition at line 45 of file PrintGeomSummary.h.

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

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

Definition at line 44 of file PrintGeomSummary.h.

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

G4VPhysicalVolume* PrintGeomSummary::theTopPV_
private

Definition at line 46 of file PrintGeomSummary.h.

Referenced by update().

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

Definition at line 47 of file PrintGeomSummary.h.

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