CMS 3D CMS Logo

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

Public Member Functions

 PrintG4Solids (edm::ParameterSet const &p)
 
 ~PrintG4Solids () override=default
 
- Public Member Functions inherited from SimWatcher
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 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 dumpSummary (std::ostream &out=G4cout)
 
G4VPhysicalVolume * getTopPV ()
 
std::string reducedName (const std::string &name)
 
bool select (const std::string &name, const std::string &shape) const
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

const bool dd4hep_
 
const std::vector< std::string > solids_
 
G4VPhysicalVolume * theTopPV_
 
const std::vector< std::string > types_
 

Additional Inherited Members

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

Detailed Description

Definition at line 34 of file PrintG4Solids.cc.

Constructor & Destructor Documentation

◆ PrintG4Solids()

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

Definition at line 53 of file PrintG4Solids.cc.

References dd4hep_, and ecalTB2006H4_GenSimDigiReco_cfg::G4cout.

54  : dd4hep_(p.getUntrackedParameter<bool>("dd4hep")),
55  solids_(p.getUntrackedParameter<std::vector<std::string> >("dumpVolumes")),
56  types_(p.getUntrackedParameter<std::vector<std::string> >("dumpShapes")) {
57  G4cout << "PrintG4Solids:: initialised for printing information about G4VSolids for version dd4heP:" << dd4hep_
58  << G4endl;
59 }
const std::vector< std::string > types_
const bool dd4hep_
const std::vector< std::string > solids_

◆ ~PrintG4Solids()

PrintG4Solids::~PrintG4Solids ( )
overridedefault

Member Function Documentation

◆ dumpSummary()

void PrintG4Solids::dumpSummary ( std::ostream &  out = G4cout)
private

Definition at line 68 of file PrintG4Solids.cc.

References hltPFPuppi_cfi::cone, angle_units::operators::convertRadToDeg(), dd4hep_, compareTotals::hist, isotrackApplyRegressor::k, mergeVDriftHistosByStation::name, EgammaValidation_cff::num, MillePedeFileConverter_cfg::out, reducedName(), select(), AlCaHLTBitMon_QueryRunRegistry::string, and theTopPV_.

Referenced by update().

68  {
69  //---------- Dump number of objects of each class
70  out << " @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
71  if (theTopPV_ == nullptr) {
72  out << " No volume created " << G4endl;
73  return;
74  }
75  out << " @@@ Geometry built inside world volume: " << theTopPV_->GetName() << G4endl;
76  // Get number of solids (< # LV if several LV share a solid)
77  const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
78  std::vector<G4LogicalVolume *>::const_iterator lvcite;
79  std::set<G4VSolid *> theSolids;
80  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
81  G4VSolid *solid = (*lvcite)->GetSolid();
82  std::string name = static_cast<std::string>(solid->GetName());
83  if (dd4hep_)
85  std::string type = static_cast<std::string>(solid->GetEntityType());
86  if (select(name, type))
87  theSolids.insert(solid);
88  }
89  out << " Number of G4VSolid's: " << theSolids.size() << G4endl;
90  std::set<G4VSolid *>::const_iterator solid;
91  for (solid = theSolids.begin(); solid != theSolids.end(); solid++) {
92  G4String type = (*solid)->GetEntityType();
93  std::string name = static_cast<std::string>((*solid)->GetName());
94  if (dd4hep_)
96  out << name << ":" << type << " Volume " << (*solid)->GetCubicVolume();
97  if (type == "G4Box") {
98  const G4Box *box = static_cast<const G4Box *>(*solid);
99  out << " dx:dy:dz " << box->GetXHalfLength() << ":" << box->GetYHalfLength() << ":" << box->GetZHalfLength();
100  } else if (type == "G4Tubs") {
101  const G4Tubs *tube = static_cast<const G4Tubs *>(*solid);
102  out << " rin:rout:dz:phistart:dphi " << tube->GetInnerRadius() << ":" << tube->GetOuterRadius() << ":"
103  << tube->GetZHalfLength() << ":" << convertRadToDeg(tube->GetStartPhiAngle()) << ":"
104  << convertRadToDeg(tube->GetDeltaPhiAngle());
105  } else if (type == "G4Cons") {
106  const G4Cons *cone = static_cast<const G4Cons *>(*solid);
107  out << " rinminus:routminus:rinplus:routplus:dz:phistart:dphi " << cone->GetInnerRadiusMinusZ() << ":"
108  << cone->GetOuterRadiusMinusZ() << ":" << cone->GetInnerRadiusPlusZ() << ":" << cone->GetOuterRadiusPlusZ()
109  << ":" << cone->GetZHalfLength() << ":" << convertRadToDeg(cone->GetStartPhiAngle()) << ":"
110  << convertRadToDeg(cone->GetDeltaPhiAngle());
111  } else if (type == "G4Trap") {
112  const G4Trap *trap = static_cast<const G4Trap *>(*solid);
113  out << " zhalf:yl1:xl11:xl12:tana1:yl2:xl21:xl22:tana2 " << trap->GetZHalfLength() << ":"
114  << trap->GetYHalfLength1() << ":" << trap->GetXHalfLength1() << ":" << trap->GetXHalfLength2() << ":"
115  << trap->GetTanAlpha1() << ":" << trap->GetYHalfLength2() << ":" << trap->GetXHalfLength3() << ":"
116  << trap->GetXHalfLength4() << ":" << trap->GetTanAlpha2();
117  } else if (type == "G4Trd") {
118  const G4Trd *trd = static_cast<const G4Trd *>(*solid);
119  out << " xl1:xl2:yl1:yl2:zhalf " << trd->GetXHalfLength1() << ":" << trd->GetXHalfLength2() << ":"
120  << trd->GetYHalfLength1() << ":" << trd->GetYHalfLength2() << ":" << trd->GetZHalfLength();
121  } else if (type == "G4Polycone") {
122  const G4Polycone *cone = static_cast<const G4Polycone *>(*solid);
123  const auto hist = cone->GetOriginalParameters();
124  int num = hist->Num_z_planes;
125  out << " angle " << convertRadToDeg(hist->Start_angle) << ":" << convertRadToDeg(hist->Opening_angle) << " with "
126  << num << " planes:";
127  for (int k = 0; k < num; ++k)
128  out << " [" << k << "] " << hist->Z_values[k] << ":" << hist->Rmin[k] << ":" << hist->Rmax[k];
129  } else if (type == "G4Polyhedra") {
130  const G4Polyhedra *pgon = static_cast<const G4Polyhedra *>(*solid);
131  const auto hist = pgon->GetOriginalParameters();
132  int num = hist->Num_z_planes;
133  out << " angle " << convertRadToDeg(hist->Start_angle) << ":" << convertRadToDeg(hist->Opening_angle) << " with "
134  << hist->numSide << " sides and " << num << " planes:";
135  for (int k = 0; k < num; ++k)
136  out << " [" << k << "] " << hist->Z_values[k] << ":" << hist->Rmin[k] << ":" << hist->Rmax[k];
137  } else if (type == "G4ExtrudedSolid") {
138  const G4ExtrudedSolid *pgon = static_cast<const G4ExtrudedSolid *>(*solid);
139  int vert = pgon->GetNofVertices();
140  int numz = pgon->GetNofZSections();
141  out << " " << vert << " vertices:";
142  for (int k = 0; k < vert; ++k)
143  out << " [" << k << "] " << pgon->GetVertex(k);
144  out << "; and " << numz << " z-sections:";
145  for (int k = 0; k < numz; ++k) {
146  const auto &zsec = pgon->GetZSection(k);
147  out << " [" << k << "] " << zsec.fZ << ":" << zsec.fScale << ":" << zsec.fOffset;
148  }
149  }
150  out << G4endl;
151  }
152 }
std::string reducedName(const std::string &name)
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
G4VPhysicalVolume * theTopPV_
const bool dd4hep_
bool select(const std::string &name, const std::string &shape) const

◆ getTopPV()

G4VPhysicalVolume * PrintG4Solids::getTopPV ( )
private

Definition at line 154 of file PrintG4Solids.cc.

Referenced by update().

154  {
155  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
156 }

◆ reducedName()

std::string PrintG4Solids::reducedName ( const std::string &  name)
private

Definition at line 158 of file PrintG4Solids.cc.

References dqmdumpme::first, dqmdumpme::last, isotrackTrainRegressor::loc, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dumpSummary().

158  {
159  std::string nam(name);
160  uint32_t first = ((name.find(':') == std::string::npos) ? 0 : (name.find(':') + 1));
161  uint32_t last(name.size() + 1);
162  uint32_t loc(first);
163  while (true) {
164  if (name.find('_', loc) == std::string::npos)
165  break;
166  if (((loc + 5) < name.size()) && (name.substr(loc, 5) == "shape")) {
167  last = loc;
168  break;
169  }
170  loc = name.find('_', loc) + 1;
171  if (loc > name.size())
172  break;
173  }
174  nam = name.substr(first, last - first - 1);
175  if ((last < name.size()) && (name.substr(name.size() - 5, 5) == "_refl"))
176  nam += "_refl";
177  return nam;
178 }

◆ select()

bool PrintG4Solids::select ( const std::string &  name,
const std::string &  shape 
) const
private

Definition at line 180 of file PrintG4Solids.cc.

References spr::find(), RemoveAddSevLevel::flag, mergeVDriftHistosByStation::name, solids_, and types_.

Referenced by dumpSummary().

180  {
181  bool flag(true);
182  if (!solids_.empty())
183  flag = (flag && (std::find(solids_.begin(), solids_.end(), name) != solids_.end()));
184  if (!types_.empty())
185  flag = (flag && (std::find(types_.begin(), types_.end(), type) != types_.end()));
186  return flag;
187 }
const std::vector< std::string > types_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const std::vector< std::string > solids_

◆ update()

void PrintG4Solids::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 61 of file PrintG4Solids.cc.

References dumpSummary(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getTopPV(), and theTopPV_.

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

61  {
62  //Now take action
63  theTopPV_ = getTopPV();
64 
66 }
void dumpSummary(std::ostream &out=G4cout)
G4VPhysicalVolume * theTopPV_
G4VPhysicalVolume * getTopPV()

Member Data Documentation

◆ dd4hep_

const bool PrintG4Solids::dd4hep_
private

Definition at line 47 of file PrintG4Solids.cc.

Referenced by dumpSummary(), and PrintG4Solids().

◆ solids_

const std::vector<std::string> PrintG4Solids::solids_
private

Definition at line 48 of file PrintG4Solids.cc.

Referenced by select().

◆ theTopPV_

G4VPhysicalVolume* PrintG4Solids::theTopPV_
private

Definition at line 50 of file PrintG4Solids.cc.

Referenced by dumpSummary(), and update().

◆ types_

const std::vector<std::string> PrintG4Solids::types_
private

Definition at line 49 of file PrintG4Solids.cc.

Referenced by select().