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)
 
void fillPV (G4VPhysicalVolume *pv)
 
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< G4VPhysicalVolume * > pvs_
 
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::PrintGeomSummary ( edm::ParameterSet const &  p)

Definition at line 32 of file PrintGeomSummary.cc.

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 }

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, cuy::ii, nodeNames_, AlCaHLTBitMon_ParallelJobs::p, and solidShape_.

◆ ~PrintGeomSummary()

PrintGeomSummary::~PrintGeomSummary ( )
override

Definition at line 61 of file PrintGeomSummary.cc.

61 {}

Member Function Documentation

◆ addName()

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

Definition at line 194 of file PrintGeomSummary.cc.

194  {
195  bool refl(false);
196  if (name.find("_refl") < name.size()) {
197  refl = true;
198  name = name.substr(0, (name.find("_refl")));
199  }
200  std::map<std::string, DDSolidShape>::const_iterator jt = solidMap_.find(name);
201  DDSolidShape shape = (jt == solidMap_.end()) ? DDSolidShape::dd_not_init : jt->second;
202  std::map<DDSolidShape, std::pair<int, int>>::iterator itr = kount_.find(shape);
203  if (itr == kount_.end()) {
204  kount_[shape] = (refl) ? std::pair<int, int>(0, 1) : std::pair<int, int>(1, 0);
205  } else {
206  kount_[shape] = (refl) ? std::pair<int, int>(((itr->second).first), ++((itr->second).second))
207  : std::pair<int, int>(++((itr->second).first), ((itr->second).second));
208  }
209 }

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

Referenced by dumpSummary().

◆ addSolid()

void PrintGeomSummary::addSolid ( const DDLogicalPart part)
private

Definition at line 90 of file PrintGeomSummary.cc.

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 }

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

Referenced by update().

◆ dumpSummary()

void PrintGeomSummary::dumpSummary ( std::ostream &  out,
std::string  name 
)
private

Definition at line 158 of file PrintGeomSummary.cc.

158  {
159  //---------- Dump number of objects of each class
160  out << G4endl << G4endl << "@@@@@@@@@@@@@@@@@@ Dumping Summary For Node " << name << G4endl;
161  out << " Number of G4VSolid's: " << sls_.size() << G4endl;
162  out << " Number of G4LogicalVolume's: " << lvs_.size() << G4endl;
163  out << " Number of Touchable's: " << touch_.size() << G4endl;
164  //First the solids
165  out << G4endl << "Occurence of each type of shape among Solids" << G4endl;
166  kount_.clear();
167  for (std::vector<G4VSolid*>::iterator it = sls_.begin(); it != sls_.end(); ++it) {
168  std::string name = (*it)->GetName();
169  addName(name);
170  }
171  printSummary(out);
172  //Then the logical volumes
173  out << G4endl << "Occurence of each type of shape among Logical Volumes" << G4endl;
174  kount_.clear();
175  for (std::vector<G4LogicalVolume*>::iterator it = lvs_.begin(); it != lvs_.end(); ++it) {
176  std::string name = ((*it)->GetSolid())->GetName();
177  addName(name);
178  }
179  printSummary(out);
180  //Finally the touchables
181  out << G4endl << "Occurence of each type of shape among Touchables" << G4endl;
182  kount_.clear();
183  for (std::vector<G4LogicalVolume*>::iterator it = touch_.begin(); it != touch_.end(); ++it) {
184  std::string name = ((*it)->GetSolid())->GetName();
185  addName(name);
186  }
187  printSummary(out);
188 }

References addName(), kount_, lvs_, Skims_PA_cff::name, MillePedeFileConverter_cfg::out, printSummary(), sls_, AlCaHLTBitMon_QueryRunRegistry::string, and touch_.

Referenced by update().

◆ fillLV()

void PrintGeomSummary::fillLV ( G4LogicalVolume *  lv)
private

Definition at line 140 of file PrintGeomSummary.cc.

140  {
141  if (std::find(lvs_.begin(), lvs_.end(), lv) == lvs_.end())
142  lvs_.push_back(lv);
143  G4VSolid* sl = lv->GetSolid();
144  if (std::find(sls_.begin(), sls_.end(), sl) == sls_.end())
145  sls_.push_back(sl);
146  touch_.push_back(lv);
147  for (int ii = 0; ii < (int)(lv->GetNoDaughters()); ii++)
148  fillLV(lv->GetDaughter(ii)->GetLogicalVolume());
149 }

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

Referenced by update().

◆ fillPV()

void PrintGeomSummary::fillPV ( G4VPhysicalVolume *  pv)
private

Definition at line 151 of file PrintGeomSummary.cc.

151  {
152  if (std::find(pvs_.begin(), pvs_.end(), pv) == pvs_.end())
153  pvs_.push_back(pv);
154  for (int ii = 0; ii < (int)(pv->GetLogicalVolume()->GetNoDaughters()); ii++)
155  fillPV(pv->GetLogicalVolume()->GetDaughter(ii));
156 }

References spr::find(), cuy::ii, createfilelist::int, MetAnalyzer::pv(), and pvs_.

Referenced by update().

◆ getTopPV()

G4VPhysicalVolume * PrintGeomSummary::getTopPV ( )
private

Definition at line 190 of file PrintGeomSummary.cc.

190  {
191  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
192 }

Referenced by update().

◆ printSummary()

void PrintGeomSummary::printSummary ( std::ostream &  out)
private

Definition at line 211 of file PrintGeomSummary.cc.

211  {
212  int k(0);
213  for (std::map<DDSolidShape, std::pair<int, int>>::iterator itr = kount_.begin(); itr != kount_.end(); ++itr, ++k) {
214  std::string shape = solidShape_[itr->first];
215  out << "Shape [" << k << "] " << shape << " # " << (itr->second).first << " : " << (itr->second).second << G4endl;
216  }
217 }

References dqmdumpme::first, dqmdumpme::k, kount_, genParticles_cff::map, MillePedeFileConverter_cfg::out, solidShape_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dumpSummary().

◆ update() [1/2]

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.

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 }

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [2/2]

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.

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();
110 
111  pvs_.clear();
112  fillPV(theTopPV_);
113  G4cout << " Number of G4VPhysicalVolume's for " << name << ": " << pvs_.size() << G4endl;
114 
115  for (unsigned int k = 0; k < nodeNames_.size(); ++k) {
116  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
117  std::vector<G4LogicalVolume*>::const_iterator lvcite;
118  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
119  if ((*lvcite)->GetName() == (G4String)(nodeNames_[k])) {
120  lvs_.clear();
121  sls_.clear();
122  touch_.clear();
123  fillLV(*lvcite);
125  }
126  }
127  const G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance();
128  std::vector<G4VPhysicalVolume*>::const_iterator pvcite;
129  for (pvcite = pvs->begin(); pvcite != pvs->end(); pvcite++) {
130  if ((*pvcite)->GetName() == (G4String)(nodeNames_[k])) {
131  pvs_.clear();
132  fillPV(*pvcite);
133  G4cout << " Number of G4VPhysicalVolume's for " << nodeNames_[k] << ": " << pvs_.size() << G4endl;
134  }
135  }
136  }
137  }
138 }

References dumpSummary(), fillLV(), fillPV(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getTopPV(), dqmdumpme::k, lvs_, Skims_PA_cff::name, nodeNames_, FSQDQM_cfi::pvs, pvs_, sls_, AlCaHLTBitMon_QueryRunRegistry::string, theTopPV_, and touch_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

Member Data Documentation

◆ kount_

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

Definition at line 48 of file PrintGeomSummary.h.

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

◆ lvs_

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

Definition at line 45 of file PrintGeomSummary.h.

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

◆ nodeNames_

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

Definition at line 41 of file PrintGeomSummary.h.

Referenced by PrintGeomSummary(), and update().

◆ pvs_

std::vector<G4VPhysicalVolume *> PrintGeomSummary::pvs_
private

Definition at line 47 of file PrintGeomSummary.h.

Referenced by fillPV(), and update().

◆ sls_

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

Definition at line 46 of file PrintGeomSummary.h.

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

◆ solidMap_

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

Definition at line 43 of file PrintGeomSummary.h.

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

◆ solidShape_

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

Definition at line 42 of file PrintGeomSummary.h.

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

◆ theTopPV_

G4VPhysicalVolume* PrintGeomSummary::theTopPV_
private

Definition at line 44 of file PrintGeomSummary.h.

Referenced by update().

◆ touch_

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

Definition at line 45 of file PrintGeomSummary.h.

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

PrintGeomSummary::lvs_
std::vector< G4LogicalVolume * > lvs_
Definition: PrintGeomSummary.h:45
mps_fire.i
i
Definition: mps_fire.py:355
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
DDSolidShape::ddtrap
DDSolidShape::ddtorus
PrintGeomSummary::dumpSummary
void dumpSummary(std::ostream &out, std::string name)
Definition: PrintGeomSummary.cc:158
PrintGeomSummary::pvs_
std::vector< G4VPhysicalVolume * > pvs_
Definition: PrintGeomSummary.h:47
DDSolidShape::ddpseudotrap
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
DDSolidShape::ddpolyhedra_rrz
PrintGeomSummary::solidMap_
std::map< std::string, DDSolidShape > solidMap_
Definition: PrintGeomSummary.h:43
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
PrintGeomSummary::kount_
std::map< DDSolidShape, std::pair< int, int > > kount_
Definition: PrintGeomSummary.h:48
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
PrintGeomSummary::sls_
std::vector< G4VSolid * > sls_
Definition: PrintGeomSummary.h:46
part
part
Definition: HCALResponse.h:20
DDSolidShape::ddtubs
DDCompactView::graph
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
Definition: DDCompactView.cc:58
PrintGeomSummary::solidShape_
std::map< DDSolidShape, std::string > solidShape_
Definition: PrintGeomSummary.h:42
adjl_iterator
Graph::const_adj_iterator adjl_iterator
Definition: GeometryInfoDump.cc:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DDSolidShape::ddtrunctubs
DDSolidShape::ddpolyhedra_rz
DDBase::name
const N & name() const
Definition: DDBase.h:59
PrintGeomSummary::addName
void addName(std::string name)
Definition: PrintGeomSummary.cc:194
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDCompactView::Graph
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:82
DDSolidShape::ddellipticaltube
DDSolidShape::ddsphere
DDSolidShape::ddcons
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
createfilelist.int
int
Definition: createfilelist.py:10
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
PrintGeomSummary::theTopPV_
G4VPhysicalVolume * theTopPV_
Definition: PrintGeomSummary.h:44
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
PrintGeomSummary::getTopPV
G4VPhysicalVolume * getTopPV()
Definition: PrintGeomSummary.cc:190
PrintGeomSummary::touch_
std::vector< G4LogicalVolume * > touch_
Definition: PrintGeomSummary.h:45
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
DDSolidShape::dd_not_init
FSQDQM_cfi.pvs
pvs
Definition: FSQDQM_cfi.py:12
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
PrintGeomSummary::printSummary
void printSummary(std::ostream &out)
Definition: PrintGeomSummary.cc:211
PrintGeomSummary::fillPV
void fillPV(G4VPhysicalVolume *pv)
Definition: PrintGeomSummary.cc:151
DDSolidShape::ddbox
math::Graph< DDLogicalPart, DDPosData * >::index_type
std::vector< double >::size_type index_type
Definition: Graph.h:15
PrintGeomSummary::addSolid
void addSolid(const DDLogicalPart &part)
Definition: PrintGeomSummary.cc:90
DDSolidShape::ddextrudedpolygon
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolidShape::ddshapeless
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
PrintGeomSummary::fillLV
void fillLV(G4LogicalVolume *lv)
Definition: PrintGeomSummary.cc:140
DDSolidShape::ddcuttubs
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
DDSolidShape::ddpolycone_rrz
math::Graph< DDLogicalPart, DDPosData * >
genParticles_cff.map
map
Definition: genParticles_cff.py:11
ecalTB2006H4_GenSimDigiReco_cfg.G4cout
G4cout
Definition: ecalTB2006H4_GenSimDigiReco_cfg.py:303
DDSolidShape::ddsubtraction
DDSolidShape::ddintersection
PrintGeomSummary::nodeNames_
std::vector< std::string > nodeNames_
Definition: PrintGeomSummary.h:41
truncPyr::refl
Pt3D refl(const Pt3D &p)
Definition: TruncatedPyramid.cc:144
DDSolidShape::ddunion
cuy.ii
ii
Definition: cuy.py:590
DDSolidShape::ddpolycone_rz
math::Graph< DDLogicalPart, DDPosData * >::const_adj_iterator
adj_list::const_iterator const_adj_iterator
Definition: Graph.h:105