CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
TrackerG4SimHitNumberingScheme Class Reference

#include <TrackerG4SimHitNumberingScheme.h>

Public Types

using DirectMapType = std::map< Nav_Story, unsigned int >
 
using Nav_Story = std::vector< std::pair< int, std::string > >
 

Public Member Functions

unsigned int g4ToNumberingScheme (const G4VTouchable *)
 
 TrackerG4SimHitNumberingScheme (const GeometricDet &)
 

Private Member Functions

void buildAll ()
 
void dumpG4VPV (const G4VTouchable *)
 
void touchToNavStory (const G4VTouchable *, Nav_Story &)
 

Private Attributes

bool alreadySet_
 
DirectMapType directMap_
 
const GeometricDetgeomDet_
 

Detailed Description

Definition at line 12 of file TrackerG4SimHitNumberingScheme.h.

Member Typedef Documentation

◆ DirectMapType

Definition at line 16 of file TrackerG4SimHitNumberingScheme.h.

◆ Nav_Story

using TrackerG4SimHitNumberingScheme::Nav_Story = std::vector<std::pair<int, std::string> >

Definition at line 15 of file TrackerG4SimHitNumberingScheme.h.

Constructor & Destructor Documentation

◆ TrackerG4SimHitNumberingScheme()

TrackerG4SimHitNumberingScheme::TrackerG4SimHitNumberingScheme ( const GeometricDet det)
explicit

Member Function Documentation

◆ buildAll()

void TrackerG4SimHitNumberingScheme::buildAll ( )
private

Definition at line 17 of file TrackerG4SimHitNumberingScheme.cc.

References alreadySet_, GeometricDet::deepComponents(), directMap_, Exception, geomDet_, compareTotals::hist, LogDebug, submitPVValidationJobs::t, and touchToNavStory().

Referenced by g4ToNumberingScheme().

17  {
18  if (alreadySet_)
19  return;
20  alreadySet_ = true;
21 
22  G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
23  G4Navigator theNavigator;
24  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());
25 
26  std::vector<const GeometricDet*> allSensitiveDets;
27  geomDet_->deepComponents(allSensitiveDets);
28  edm::LogVerbatim("TrackerSimInfoNumbering")
29  << " TouchableTo History: got " << allSensitiveDets.size() << " sensitive detectors from GeometricDet.";
30 
31  for (auto& theSD : allSensitiveDets) {
32  auto const& t = theSD->translation();
33  theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(), t.y(), t.z()));
34  G4TouchableHistory* hist = theNavigator.CreateTouchableHistory();
36  touchToNavStory(hist, st);
37 
38  directMap_[st] = theSD->geographicalId();
39 
40  LogDebug("TrackerSimDebugNumbering") << " INSERTING LV " << hist->GetVolume()->GetLogicalVolume()->GetName()
41  << " SD: "
42  << hist->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()->GetName()
43  << " Now size is " << directMap_.size();
44  delete hist;
45  }
46  edm::LogVerbatim("TrackerSimInfoNumbering")
47  << " TrackerG4SimHitNumberingScheme: mapped " << directMap_.size() << " detectors to Geant4.";
48 
49  if (directMap_.size() != allSensitiveDets.size()) {
50  edm::LogError("TrackerSimInfoNumbering") << " ERROR: GeomDet sensitive detectors do not match Geant4 ones.";
51  throw cms::Exception("TrackerG4SimHitNumberingScheme::buildAll")
52  << " cannot resolve structure of tracking sensitive detectors";
53  }
54 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
std::vector< std::pair< int, std::string > > Nav_Story
ConstGeometricDetContainer deepComponents() const
void touchToNavStory(const G4VTouchable *, Nav_Story &)
#define LogDebug(id)

◆ dumpG4VPV()

void TrackerG4SimHitNumberingScheme::dumpG4VPV ( const G4VTouchable *  v)
private

Definition at line 98 of file TrackerG4SimHitNumberingScheme.cc.

References dqmdumpme::k, GCP_tree_cfg::levels, and findQualityFiles::v.

Referenced by g4ToNumberingScheme().

98  {
99  int levels = v->GetHistoryDepth();
100 
101  edm::LogVerbatim("TrackerSimDebugNumbering") << " NAME : " << v->GetVolume()->GetLogicalVolume()->GetName();
102  for (int k = 0; k <= levels; k++) {
103  edm::LogVerbatim("TrackerSimInfoNumbering")
104  << " Hist: " << v->GetVolume(k)->GetLogicalVolume()->GetName() << " Copy " << v->GetVolume(k)->GetCopyNo();
105  }
106 }
Log< level::Info, true > LogVerbatim

◆ g4ToNumberingScheme()

unsigned int TrackerG4SimHitNumberingScheme::g4ToNumberingScheme ( const G4VTouchable *  v)

Definition at line 83 of file TrackerG4SimHitNumberingScheme.cc.

References alreadySet_, buildAll(), directMap_, dumpG4VPV(), touchToNavStory(), and findQualityFiles::v.

Referenced by TkAccumulatingSensitiveDetector::setDetUnitId().

83  {
84  if (alreadySet_ == false) {
85  buildAll();
86  }
88  touchToNavStory(v, st);
89 
90 #ifdef EDM_ML_DEBUG
91  dumpG4VPV(v);
92  edm::LogVerbatim("TrackerSimDebugNumbering") << " Returning: " << directMap_[st];
93 #endif
94 
95  return directMap_[st];
96 }
Log< level::Info, true > LogVerbatim
std::vector< std::pair< int, std::string > > Nav_Story
void touchToNavStory(const G4VTouchable *, Nav_Story &)

◆ touchToNavStory()

void TrackerG4SimHitNumberingScheme::touchToNavStory ( const G4VTouchable *  v,
TrackerG4SimHitNumberingScheme::Nav_Story st 
)
private

Definition at line 56 of file TrackerG4SimHitNumberingScheme.cc.

References findQualityFiles::jj, dqmdumpme::k, GCP_tree_cfg::levels, DD4hep2DDDName::noNameSpace(), and findQualityFiles::v.

Referenced by buildAll(), and g4ToNumberingScheme().

57  {
58 #ifdef EDM_ML_DEBUG
59  std::vector<int> debugint;
60  std::vector<std::string> debugstring;
61 #endif
62  int levels = v->GetHistoryDepth();
63 
64  for (int k = 0; k <= levels; ++k) {
65  if (DD4hep2DDDName::noNameSpace(static_cast<std::string>(v->GetVolume(k)->GetLogicalVolume()->GetName())) !=
66  "TOBInactive") {
67  st.emplace_back(std::pair<int, std::string>(
68  v->GetVolume(k)->GetCopyNo(),
69  DD4hep2DDDName::noNameSpace(static_cast<std::string>(v->GetVolume(k)->GetLogicalVolume()->GetName()))));
70 #ifdef EDM_ML_DEBUG
71  debugint.emplace_back(v->GetVolume(k)->GetCopyNo());
72  debugstring.emplace_back(v->GetVolume(k)->GetLogicalVolume()->GetName());
73 #endif
74  }
75  }
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("TrackerSimDebugNumbering") << " G4 TrackerG4SimHitNumberingScheme " << debugint.size();
78  for (u_int32_t jj = 0; jj < debugstring.size(); jj++)
79  edm::LogVerbatim("TrackerSimDebugNumbering") << " " << debugstring[jj];
80 #endif
81 }
Log< level::Info, true > LogVerbatim
std::string noNameSpace(const std::string &name)

Member Data Documentation

◆ alreadySet_

bool TrackerG4SimHitNumberingScheme::alreadySet_
private

Definition at line 29 of file TrackerG4SimHitNumberingScheme.h.

Referenced by buildAll(), and g4ToNumberingScheme().

◆ directMap_

DirectMapType TrackerG4SimHitNumberingScheme::directMap_
private

Definition at line 28 of file TrackerG4SimHitNumberingScheme.h.

Referenced by buildAll(), and g4ToNumberingScheme().

◆ geomDet_

const GeometricDet* TrackerG4SimHitNumberingScheme::geomDet_
private

Definition at line 30 of file TrackerG4SimHitNumberingScheme.h.

Referenced by buildAll().