CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PrintGeomSummary Class Reference
Inheritance diagram for PrintGeomSummary:
SimWatcher Observer< const BeginOfRun *>

Public Member Functions

void beginRun (edm::EventSetup const &) override
 
 PrintGeomSummary (edm::ParameterSet const &p)
 
void registerConsumes (edm::ConsumesCollector) override
 
 ~PrintGeomSummary () override=default
 
- Public Member Functions inherited from SimWatcher
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- 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 BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

edm::ESGetToken< DDCompactView, IdealGeometryRecordddcompToken_
 
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

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 37 of file PrintGeomSummary.cc.

Constructor & Destructor Documentation

◆ PrintGeomSummary()

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

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

67  : theTopPV_(nullptr) {
68  std::vector<std::string> defNames;
69  nodeNames_ = p.getUntrackedParameter<std::vector<std::string>>("NodeNames", defNames);
70  G4cout << "PrintGeomSummary:: initialised for " << nodeNames_.size() << " nodes:" << G4endl;
71  for (unsigned int ii = 0; ii < nodeNames_.size(); ii++)
72  G4cout << "Node[" << ii << "] : " << nodeNames_[ii] << G4endl;
73 
76  solidShape_[DDSolidShape::ddtrap] = "Trapezoid";
79  solidShape_[DDSolidShape::ddpolyhedra_rz] = "Polyhedra_rz";
80  solidShape_[DDSolidShape::ddpolycone_rrz] = "Polycone_rrz";
81  solidShape_[DDSolidShape::ddpolyhedra_rrz] = "Polyhedra_rrz";
83  solidShape_[DDSolidShape::ddunion] = "UnionSolid";
84  solidShape_[DDSolidShape::ddsubtraction] = "SubtractionSolid";
85  solidShape_[DDSolidShape::ddintersection] = "IntersectionSolid";
86  solidShape_[DDSolidShape::ddshapeless] = "ShapelessSolid";
87  solidShape_[DDSolidShape::ddpseudotrap] = "PseudoTrapezoid";
88  solidShape_[DDSolidShape::ddtrunctubs] = "TruncatedTube";
90  solidShape_[DDSolidShape::ddellipticaltube] = "EllipticalTube";
92  solidShape_[DDSolidShape::ddextrudedpolygon] = "ExtrudedPolygon";
94 }
std::map< DDSolidShape, std::string > solidShape_
G4VPhysicalVolume * theTopPV_
std::vector< std::string > nodeNames_
ii
Definition: cuy.py:589

◆ ~PrintGeomSummary()

PrintGeomSummary::~PrintGeomSummary ( )
overridedefault

Member Function Documentation

◆ addName()

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

Definition at line 230 of file PrintGeomSummary.cc.

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

Referenced by dumpSummary().

230  {
231  bool refl(false);
232  if (name.find("_refl") < name.size()) {
233  refl = true;
234  name = name.substr(0, (name.find("_refl")));
235  }
236  std::map<std::string, DDSolidShape>::const_iterator jt = solidMap_.find(name);
237  DDSolidShape shape = (jt == solidMap_.end()) ? DDSolidShape::dd_not_init : jt->second;
238  std::map<DDSolidShape, std::pair<int, int>>::iterator itr = kount_.find(shape);
239  if (itr == kount_.end()) {
240  kount_[shape] = (refl) ? std::pair<int, int>(0, 1) : std::pair<int, int>(1, 0);
241  } else {
242  kount_[shape] = (refl) ? std::pair<int, int>(((itr->second).first), ++((itr->second).second))
243  : std::pair<int, int>(++((itr->second).first), ((itr->second).second));
244  }
245 }
U second(std::pair< T, U > const &p)
DDSolidShape
Definition: DDSolidShapes.h:6
Pt3D refl(const Pt3D &p)
std::map< std::string, DDSolidShape > solidMap_
std::map< DDSolidShape, std::pair< int, int > > kount_

◆ addSolid()

void PrintGeomSummary::addSolid ( const DDLogicalPart part)
private

Definition at line 165 of file PrintGeomSummary.cc.

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

Referenced by beginRun().

165  {
166  const DDSolid& solid = part.solid();
167  std::map<DDSolidShape, std::string>::iterator it = solidShape_.find(solid.shape());
168  std::string name = solid.name().name();
169  if (it == solidShape_.end())
171  else
172  solidMap_[name] = it->first;
173  //G4cout << "Solid " << name << " is of shape " << solidMap_[name] << G4endl;
174 }
std::map< DDSolidShape, std::string > solidShape_
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
const N & name() const
Definition: DDBase.h:59
part
Definition: HCALResponse.h:20
std::map< std::string, DDSolidShape > solidMap_

◆ beginRun()

void PrintGeomSummary::beginRun ( edm::EventSetup const &  es)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 101 of file PrintGeomSummary.cc.

References addSolid(), ddcompToken_, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, edm::EventSetup::getData(), DDCompactView::graph(), mps_fire::i, and solidMap_.

101  {
102  const DDCompactView* cpv = &es.getData(ddcompToken_);
103 
104  const auto& gra = cpv->graph();
105 
106  using Graph = DDCompactView::Graph;
108 
109  Graph::index_type i = 0;
110  solidMap_.clear();
111  for (adjl_iterator git = gra.begin(); git != gra.end(); ++git) {
112  const DDLogicalPart& ddLP = gra.nodeData(git);
113  addSolid(ddLP);
114  ++i;
115  if (!git->empty()) {
116  // ask for children of ddLP
117  for (Graph::edge_list::const_iterator cit = git->begin(); cit != git->end(); ++cit) {
118  const DDLogicalPart& ddcurLP = gra.nodeData(cit->first);
119  addSolid(ddcurLP);
120  }
121  }
122  }
123  G4cout << "Finds " << solidMap_.size() << " different solids in the tree" << G4endl;
124 }
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:83
std::vector< double >::size_type index_type
Definition: Graph.h:15
void addSolid(const DDLogicalPart &part)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
Graph::const_adj_iterator adjl_iterator
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddcompToken_
adj_list::const_iterator const_adj_iterator
Definition: Graph.h:105
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
std::map< std::string, DDSolidShape > solidMap_

◆ dumpSummary()

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

Definition at line 194 of file PrintGeomSummary.cc.

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

Referenced by update().

194  {
195  //---------- Dump number of objects of each class
196  out << G4endl << G4endl << "@@@@@@@@@@@@@@@@@@ Dumping Summary For Node " << name << G4endl;
197  out << " Number of G4VSolid's: " << sls_.size() << G4endl;
198  out << " Number of G4LogicalVolume's: " << lvs_.size() << G4endl;
199  out << " Number of Touchable's: " << touch_.size() << G4endl;
200  //First the solids
201  out << G4endl << "Occurence of each type of shape among Solids" << G4endl;
202  kount_.clear();
203  for (std::vector<G4VSolid*>::iterator it = sls_.begin(); it != sls_.end(); ++it) {
204  std::string name = (*it)->GetName();
205  addName(name);
206  }
207  printSummary(out);
208  //Then the logical volumes
209  out << G4endl << "Occurence of each type of shape among Logical Volumes" << G4endl;
210  kount_.clear();
211  for (std::vector<G4LogicalVolume*>::iterator it = lvs_.begin(); it != lvs_.end(); ++it) {
212  std::string name = ((*it)->GetSolid())->GetName();
213  addName(name);
214  }
215  printSummary(out);
216  //Finally the touchables
217  out << G4endl << "Occurence of each type of shape among Touchables" << G4endl;
218  kount_.clear();
219  for (std::vector<G4LogicalVolume*>::iterator it = touch_.begin(); it != touch_.end(); ++it) {
220  std::string name = ((*it)->GetSolid())->GetName();
221  addName(name);
222  }
223  printSummary(out);
224 }
void addName(std::string name)
void printSummary(std::ostream &out)
std::vector< G4LogicalVolume * > touch_
std::vector< G4VSolid * > sls_
std::vector< G4LogicalVolume * > lvs_
std::map< DDSolidShape, std::pair< int, int > > kount_

◆ fillLV()

void PrintGeomSummary::fillLV ( G4LogicalVolume *  lv)
private

Definition at line 176 of file PrintGeomSummary.cc.

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

Referenced by update().

176  {
177  if (std::find(lvs_.begin(), lvs_.end(), lv) == lvs_.end())
178  lvs_.push_back(lv);
179  G4VSolid* sl = lv->GetSolid();
180  if (std::find(sls_.begin(), sls_.end(), sl) == sls_.end())
181  sls_.push_back(sl);
182  touch_.push_back(lv);
183  for (int ii = 0; ii < (int)(lv->GetNoDaughters()); ii++)
184  fillLV(lv->GetDaughter(ii)->GetLogicalVolume());
185 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< G4LogicalVolume * > touch_
void fillLV(G4LogicalVolume *lv)
ii
Definition: cuy.py:589
std::vector< G4VSolid * > sls_
std::vector< G4LogicalVolume * > lvs_

◆ fillPV()

void PrintGeomSummary::fillPV ( G4VPhysicalVolume *  pv)
private

Definition at line 187 of file PrintGeomSummary.cc.

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

Referenced by update().

187  {
188  if (std::find(pvs_.begin(), pvs_.end(), pv) == pvs_.end())
189  pvs_.push_back(pv);
190  for (int ii = 0; ii < (int)(pv->GetLogicalVolume()->GetNoDaughters()); ii++)
191  fillPV(pv->GetLogicalVolume()->GetDaughter(ii));
192 }
void fillPV(G4VPhysicalVolume *pv)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
def pv(vc)
Definition: MetAnalyzer.py:7
ii
Definition: cuy.py:589
std::vector< G4VPhysicalVolume * > pvs_

◆ getTopPV()

G4VPhysicalVolume * PrintGeomSummary::getTopPV ( )
private

Definition at line 226 of file PrintGeomSummary.cc.

Referenced by update().

226  {
227  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
228 }

◆ printSummary()

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

Definition at line 247 of file PrintGeomSummary.cc.

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

Referenced by dumpSummary().

247  {
248  int k(0);
249  for (std::map<DDSolidShape, std::pair<int, int>>::iterator itr = kount_.begin(); itr != kount_.end(); ++itr, ++k) {
250  std::string shape = solidShape_[itr->first];
251  out << "Shape [" << k << "] " << shape << " # " << (itr->second).first << " : " << (itr->second).second << G4endl;
252  }
253 }
std::map< DDSolidShape, std::string > solidShape_
DDSolidShape
Definition: DDSolidShapes.h:6
std::map< DDSolidShape, std::pair< int, int > > kount_

◆ registerConsumes()

void PrintGeomSummary::registerConsumes ( edm::ConsumesCollector  cc)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 96 of file PrintGeomSummary.cc.

References edm::BeginRun, gpuPixelDoublets::cc, ddcompToken_, and ecalTB2006H4_GenSimDigiReco_cfg::G4cout.

96  {
98  G4cout << "PrintGeomSummary::Initialize ESGetToken for DDCompactView" << G4endl;
99 }
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddcompToken_

◆ update()

void PrintGeomSummary::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 126 of file PrintGeomSummary.cc.

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().

126  {
127  theTopPV_ = getTopPV();
128  if (theTopPV_) {
129  lvs_.clear();
130  sls_.clear();
131  touch_.clear();
132  fillLV(theTopPV_->GetLogicalVolume());
133  std::string name = theTopPV_->GetName();
135 
136  pvs_.clear();
137  fillPV(theTopPV_);
138  G4cout << " Number of G4VPhysicalVolume's for " << name << ": " << pvs_.size() << G4endl;
139 
140  for (unsigned int k = 0; k < nodeNames_.size(); ++k) {
141  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
142  std::vector<G4LogicalVolume*>::const_iterator lvcite;
143  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
144  if ((*lvcite)->GetName() == (G4String)(nodeNames_[k])) {
145  lvs_.clear();
146  sls_.clear();
147  touch_.clear();
148  fillLV(*lvcite);
150  }
151  }
152  const G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance();
153  std::vector<G4VPhysicalVolume*>::const_iterator pvcite;
154  for (pvcite = pvs->begin(); pvcite != pvs->end(); pvcite++) {
155  if ((*pvcite)->GetName() == (G4String)(nodeNames_[k])) {
156  pvs_.clear();
157  fillPV(*pvcite);
158  G4cout << " Number of G4VPhysicalVolume's for " << nodeNames_[k] << ": " << pvs_.size() << G4endl;
159  }
160  }
161  }
162  }
163 }
void fillPV(G4VPhysicalVolume *pv)
G4VPhysicalVolume * getTopPV()
G4VPhysicalVolume * theTopPV_
std::vector< G4LogicalVolume * > touch_
std::vector< std::string > nodeNames_
void fillLV(G4LogicalVolume *lv)
std::vector< G4VSolid * > sls_
void dumpSummary(std::ostream &out, std::string name)
std::vector< G4VPhysicalVolume * > pvs_
std::vector< G4LogicalVolume * > lvs_

Member Data Documentation

◆ ddcompToken_

edm::ESGetToken<DDCompactView, IdealGeometryRecord> PrintGeomSummary::ddcompToken_
private

Definition at line 56 of file PrintGeomSummary.cc.

Referenced by beginRun(), and registerConsumes().

◆ kount_

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

Definition at line 64 of file PrintGeomSummary.cc.

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

◆ lvs_

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

Definition at line 61 of file PrintGeomSummary.cc.

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

◆ nodeNames_

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

Definition at line 57 of file PrintGeomSummary.cc.

Referenced by PrintGeomSummary(), and update().

◆ pvs_

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

Definition at line 63 of file PrintGeomSummary.cc.

Referenced by fillPV(), and update().

◆ sls_

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

Definition at line 62 of file PrintGeomSummary.cc.

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

◆ solidMap_

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

Definition at line 59 of file PrintGeomSummary.cc.

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

◆ solidShape_

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

Definition at line 58 of file PrintGeomSummary.cc.

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

◆ theTopPV_

G4VPhysicalVolume* PrintGeomSummary::theTopPV_
private

Definition at line 60 of file PrintGeomSummary.cc.

Referenced by update().

◆ touch_

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

Definition at line 61 of file PrintGeomSummary.cc.

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