Skip to content

Commit

Permalink
Merge pull request cms-sw#33443 from bsunanda/Run3-gex68
Browse files Browse the repository at this point in the history
Run3-gex68 Check in more detail the contents of the geometry
  • Loading branch information
cmsbuild authored Apr 17, 2021
2 parents 0813868 + ab76b8f commit c2cb6ca
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 47 deletions.
1 change: 1 addition & 0 deletions SimG4Core/PrintGeomInfo/interface/PrintGeomInfoAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PrintGeomInfoAction : public SimWatcher, public Observer<const BeginOfJob*
std::string name_;
int nchar_;
std::string fileMat_, fileSolid_, fileLV_, filePV_, fileTouch_;
bool fileDetail_;
std::vector<std::string> names_;
G4VPhysicalVolume* theTopPV_;
G4NavigationHistory fHistory_;
Expand Down
41 changes: 31 additions & 10 deletions SimG4Core/PrintGeomInfo/src/PrintGeomInfoAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ PrintGeomInfoAction::PrintGeomInfoAction(const edm::ParameterSet &p) {
fileLV_ = p.getUntrackedParameter<std::string>("LVFileName", "");
filePV_ = p.getUntrackedParameter<std::string>("PVFileName", "");
fileTouch_ = p.getUntrackedParameter<std::string>("TouchFileName", "");
fileDetail_ = p.getUntrackedParameter<bool>("FileDetail", false);
G4cout << "PrintGeomInfoAction:: initialised for dd4hep " << dd4hep_ << " with verbosity levels:"
<< " Summary " << dumpSummary_ << " LVTree " << dumpLVTree_ << " LVList " << dumpLVList_ << " Material "
<< dumpMaterial_ << "\n "
Expand All @@ -72,8 +73,8 @@ PrintGeomInfoAction::PrintGeomInfoAction(const edm::ParameterSet &p) {
<< " Touchable " << dumpTouch_ << " for names (0-" << nchar_ << ") = " << name_
<< "\n "
<< " Sensitive " << dumpSense_ << " Files " << fileMat_ << ":" << fileSolid_ << ":" << fileLV_ << ":"
<< filePV_ << ":" << fileTouch_ << "\n "
<< "for " << names_.size() << " names:";
<< filePV_ << ":" << fileTouch_ << " FileDetail " << fileDetail_
<< "\n for " << names_.size() << " names:";
for (unsigned int i = 0; i < names_.size(); i++)
G4cout << " " << names_[i];
G4cout << G4endl;
Expand Down Expand Up @@ -432,31 +433,51 @@ void PrintGeomInfoAction::dumpInFile() {
if (!fileMat_.empty()) {
const G4MaterialTable *matTab = G4Material::GetMaterialTable();
std::ofstream fout(fileMat_.c_str());
for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++)
fout << (*matite)->GetName() << "\n";
for (std::vector<G4Material *>::const_iterator matite = matTab->begin(); matite != matTab->end(); matite++) {
if (!fileDetail_)
fout << (*matite)->GetName() << "\n";
else
fout << (*matite)->GetName() << " " << (*matite)->GetRadlen() << " " << (*matite)->GetNuclearInterLength()
<< "\n";
}
fout.close();
}
const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
if (!fileSolid_.empty()) {
std::ofstream fout(fileSolid_.c_str());
for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
fout << (*lvcite)->GetSolid()->GetName() << "\n";
if (!fileDetail_)
fout << (*lvcite)->GetSolid()->GetName() << "\n";
else
fout << (*lvcite)->GetSolid()->GetName() << " " << (*lvcite)->GetSolid()->GetCubicVolume() << "\n";
fout.close();
}
if (!fileLV_.empty()) {
std::ofstream fout(fileLV_.c_str());
for (std::vector<G4LogicalVolume *>::const_iterator lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
fout << (*lvcite)->GetName() << "\n";
if (!fileDetail_)
fout << (*lvcite)->GetName() << "\n";
else
fout << (*lvcite)->GetName() << " " << (*lvcite)->GetMass(false, false) << "\n";
fout.close();
}
if (!filePV_.empty()) {
const G4PhysicalVolumeStore *pvs = G4PhysicalVolumeStore::GetInstance();
std::ofstream fout(filePV_.c_str());
for (std::vector<G4VPhysicalVolume *>::const_iterator pvcite = pvs->begin(); pvcite != pvs->end(); pvcite++) {
if (dd4hep_)
fout << (*pvcite)->GetName() << "\n";
else
fout << (*pvcite)->GetName() << "_" << (*pvcite)->GetCopyNo() << "\n";
if (fileDetail_) {
if (dd4hep_)
fout << (*pvcite)->GetName() << " " << (*pvcite)->GetTranslation().x() << " "
<< (*pvcite)->GetTranslation().y() << " " << (*pvcite)->GetTranslation().z() << "\n";
else
fout << (*pvcite)->GetName() << "_" << (*pvcite)->GetCopyNo() << " " << (*pvcite)->GetTranslation().x()
<< " " << (*pvcite)->GetTranslation().y() << " " << (*pvcite)->GetTranslation().z() << "\n";
} else {
if (dd4hep_)
fout << (*pvcite)->GetName() << "\n";
else
fout << (*pvcite)->GetName() << "_" << (*pvcite)->GetCopyNo() << "\n";
}
}
fout.close();
}
Expand Down
Loading

0 comments on commit c2cb6ca

Please sign in to comment.