CMS 3D CMS Logo

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

Public Member Functions

 PrintG4Touch (edm::ParameterSet const &p)
 
 ~PrintG4Touch () 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 add1touchable (G4LogicalVolume *lv, int &nTouch)
 
int countNoTouchables ()
 
void dumpSummary (std::ostream &out=G4cout)
 
void dumpTouch (G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=G4cout)
 
G4LogicalVolume * getTopLV ()
 
G4VPhysicalVolume * getTopPV ()
 
void getTouch (G4VPhysicalVolume *pv, unsigned int leafDepth, unsigned int copym, std::vector< std::string > &touches)
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

bool dd4hep_
 
G4NavigationHistory fHistory_
 
G4VPhysicalVolume * theTopPV_
 
bool verbosity_
 

Additional Inherited Members

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

Detailed Description

Definition at line 35 of file PrintG4Touch.cc.

Constructor & Destructor Documentation

◆ PrintG4Touch()

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

Definition at line 56 of file PrintG4Touch.cc.

References dd4hep_, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, AlCaHLTBitMon_ParallelJobs::p, and verbosity_.

56  {
57  dd4hep_ = p.getUntrackedParameter<bool>("dd4hep", false);
58  verbosity_ = p.getUntrackedParameter<bool>("verbosity", false);
59  G4cout << "PrintG4Touch:: initialised for dd4hep " << dd4hep_ << " with verbosity levels:" << verbosity_ << G4endl;
60 }

◆ ~PrintG4Touch()

PrintG4Touch::~PrintG4Touch ( )
overridedefault

Member Function Documentation

◆ add1touchable()

void PrintG4Touch::add1touchable ( G4LogicalVolume *  lv,
int &  nTouch 
)
private

Definition at line 112 of file PrintG4Touch.cc.

References cuy::ii.

Referenced by countNoTouchables().

112  {
113  int siz = lv->GetNoDaughters();
114  for (int ii = 0; ii < siz; ii++)
115  add1touchable(lv->GetDaughter(ii)->GetLogicalVolume(), ++nTouch);
116 }
void add1touchable(G4LogicalVolume *lv, int &nTouch)
ii
Definition: cuy.py:589

◆ countNoTouchables()

int PrintG4Touch::countNoTouchables ( )
private

Definition at line 105 of file PrintG4Touch.cc.

References add1touchable(), and getTopLV().

Referenced by dumpSummary().

105  {
106  int nTouch = 0;
107  G4LogicalVolume *lv = getTopLV();
108  add1touchable(lv, nTouch);
109  return nTouch;
110 }
G4LogicalVolume * getTopLV()
void add1touchable(G4LogicalVolume *lv, int &nTouch)

◆ dumpSummary()

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

Definition at line 79 of file PrintG4Touch.cc.

References countNoTouchables(), dd4hep_, DD4hep2DDDName::namePV(), MillePedeFileConverter_cfg::out, FSQDQM_cfi::pvs, and theTopPV_.

Referenced by update().

79  {
80  //---------- Dump number of objects of each class
81  out << " @@@@@@@@@@@@@@@@@@ Dumping G4 geometry objects Summary " << G4endl;
82  if (theTopPV_ == nullptr) {
83  out << " No volume created " << G4endl;
84  return;
85  }
86  out << " @@@ Geometry built inside world volume: "
87  << DD4hep2DDDName::namePV(static_cast<std::string>(theTopPV_->GetName()), dd4hep_) << G4endl;
88  // Get number of solids (< # LV if several LV share a solid)
89  const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
90  std::vector<G4LogicalVolume *>::const_iterator lvcite;
91  std::set<G4VSolid *> theSolids;
92  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
93  theSolids.insert((*lvcite)->GetSolid());
94  out << " Number of G4VSolid's: " << theSolids.size() << G4endl;
95  out << " Number of G4LogicalVolume's: " << lvs->size() << G4endl;
96  const G4PhysicalVolumeStore *pvs = G4PhysicalVolumeStore::GetInstance();
97  out << " Number of G4VPhysicalVolume's: " << pvs->size() << G4endl;
98  out << " Number of Touchable's: " << countNoTouchables() << G4endl;
99  const G4MaterialTable *matTab = G4Material::GetMaterialTable();
100  out << " Number of G4Material's: " << matTab->size() << G4endl;
101  const G4RegionStore *regs = G4RegionStore::GetInstance();
102  out << " Number of G4Region's: " << regs->size() << G4endl;
103 }
G4VPhysicalVolume * theTopPV_
Definition: PrintG4Touch.cc:52
int countNoTouchables()
std::string namePV(const std::string &name, bool dd4hep)

◆ dumpTouch()

void PrintG4Touch::dumpTouch ( G4VPhysicalVolume *  pv,
unsigned int  leafDepth,
std::ostream &  out = G4cout 
)
private

Definition at line 118 of file PrintG4Touch.cc.

References angle_units::operators::convertRadToDeg(), dd4hep_, fHistory_, DD4hep2DDDName::nameSolid(), MillePedeFileConverter_cfg::out, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by update().

118  {
119  if (leafDepth == 0)
120  fHistory_.SetFirstEntry(pv);
121  else
122  fHistory_.NewLevel(pv, kNormal, pv->GetCopyNo());
123 
124  G4LogicalVolume *lv = pv->GetLogicalVolume();
125 
126  G4ThreeVector globalpoint = fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
127  std::string mother = (pv->GetMotherLogical())
129  static_cast<std::string>(pv->GetMotherLogical()->GetSolid()->GetName()), dd4hep_))
130  : "World";
131  std::string lvname = DD4hep2DDDName::nameSolid(static_cast<std::string>(lv->GetName()), dd4hep_);
132  out << leafDepth << "### VOLUME = " << lvname << " Copy No " << pv->GetCopyNo() << " in " << mother
133  << " global position of centre " << globalpoint << " (r = " << globalpoint.perp()
134  << ", phi = " << convertRadToDeg(globalpoint.phi()) << ")" << G4endl;
135 
136  int NoDaughters = lv->GetNoDaughters();
137  while ((NoDaughters--) > 0) {
138  G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
139  if (!pvD->IsReplicated())
140  dumpTouch(pvD, leafDepth + 1, out);
141  }
142 
143  if (leafDepth > 0)
144  fHistory_.BackLevel();
145 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=G4cout)
G4NavigationHistory fHistory_
Definition: PrintG4Touch.cc:53
std::string nameSolid(const std::string &name, bool dd4hep)

◆ getTopLV()

G4LogicalVolume * PrintG4Touch::getTopLV ( )
private

Definition at line 185 of file PrintG4Touch.cc.

References theTopPV_.

Referenced by countNoTouchables().

185 { return theTopPV_->GetLogicalVolume(); }
G4VPhysicalVolume * theTopPV_
Definition: PrintG4Touch.cc:52

◆ getTopPV()

G4VPhysicalVolume * PrintG4Touch::getTopPV ( )
private

Definition at line 181 of file PrintG4Touch.cc.

Referenced by update().

181  {
182  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
183 }

◆ getTouch()

void PrintG4Touch::getTouch ( G4VPhysicalVolume *  pv,
unsigned int  leafDepth,
unsigned int  copym,
std::vector< std::string > &  touches 
)
private

Definition at line 147 of file PrintG4Touch.cc.

References filterCSVwithJSON::copy, dd4hep_, fHistory_, Skims_PA_cff::name, DD4hep2DDDName::nameSolid(), AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

Referenced by update().

150  {
151  if (leafDepth == 0)
152  fHistory_.SetFirstEntry(pv);
153  else
154  fHistory_.NewLevel(pv, kNormal, pv->GetCopyNo());
155 
156  std::string mother = (pv->GetMotherLogical())
158  static_cast<std::string>(pv->GetMotherLogical()->GetSolid()->GetName()), dd4hep_))
159  : "World";
160 
161  G4LogicalVolume *lv = pv->GetLogicalVolume();
162  std::string lvname = DD4hep2DDDName::nameSolid(static_cast<std::string>(lv->GetSolid()->GetName()), dd4hep_);
163  unsigned int copy = static_cast<unsigned int>(pv->GetCopyNo());
164 
165  std::string type = static_cast<std::string>(lv->GetSolid()->GetEntityType());
166 
167  std::string name = lvname + " " + std::to_string(copy) + " " + mother + " " + std::to_string(copym) + " " + type;
168  touches.emplace_back(name);
169 
170  int NoDaughters = lv->GetNoDaughters();
171  while ((NoDaughters--) > 0) {
172  G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
173  if (!pvD->IsReplicated())
174  getTouch(pvD, leafDepth + 1, copy, touches);
175  }
176 
177  if (leafDepth > 0)
178  fHistory_.BackLevel();
179 }
void getTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, unsigned int copym, std::vector< std::string > &touches)
static std::string to_string(const XMLCh *ch)
G4NavigationHistory fHistory_
Definition: PrintG4Touch.cc:53
std::string nameSolid(const std::string &name, bool dd4hep)

◆ update()

void PrintG4Touch::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 62 of file PrintG4Touch.cc.

References dumpSummary(), dumpTouch(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getTopPV(), getTouch(), jetUpdater_cfi::sort, theTopPV_, and verbosity_.

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

62  {
63  //Now take action
64  theTopPV_ = getTopPV();
65 
67 
68  std::vector<std::string> touches;
69  getTouch(theTopPV_, 0, 1, touches);
70  std::sort(touches.begin(), touches.end());
71  for (const auto &touch : touches)
72  G4cout << touch << G4endl;
73 
74  //---------- Dump LV and PV information
75  if (verbosity_)
77 }
G4VPhysicalVolume * theTopPV_
Definition: PrintG4Touch.cc:52
void getTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, unsigned int copym, std::vector< std::string > &touches)
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, std::ostream &out=G4cout)
void dumpSummary(std::ostream &out=G4cout)
Definition: PrintG4Touch.cc:79
G4VPhysicalVolume * getTopPV()

Member Data Documentation

◆ dd4hep_

bool PrintG4Touch::dd4hep_
private

Definition at line 51 of file PrintG4Touch.cc.

Referenced by dumpSummary(), dumpTouch(), getTouch(), and PrintG4Touch().

◆ fHistory_

G4NavigationHistory PrintG4Touch::fHistory_
private

Definition at line 53 of file PrintG4Touch.cc.

Referenced by dumpTouch(), and getTouch().

◆ theTopPV_

G4VPhysicalVolume* PrintG4Touch::theTopPV_
private

Definition at line 52 of file PrintG4Touch.cc.

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

◆ verbosity_

bool PrintG4Touch::verbosity_
private

Definition at line 51 of file PrintG4Touch.cc.

Referenced by PrintG4Touch(), and update().