CMS 3D CMS Logo

TrackerG4SimHitNumberingScheme.cc
Go to the documentation of this file.
2 
7 
9 
10 #include "G4TransportationManager.hh"
11 #include "G4Navigator.hh"
12 #include "G4VTouchable.hh"
13 #include "G4TouchableHistory.hh"
14 #include "G4VSensitiveDetector.hh"
15 
16 //#define DEBUG
17 
19  const GeometricDet& det )
20  : alreadySet(false), myCompactView(&cpv), myGeomDet(&det) {
21 }
22 
24 }
25 
27  if (alreadySet) return;
28  alreadySet = true;
29 
30  G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
31  G4Navigator theNavigator;
32  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());
33 
34  std::vector<const GeometricDet*> allSensitiveDets;
35  myGeomDet->deepComponents(allSensitiveDets);
36  edm::LogInfo("TrackerSimInfoNumbering")
37  <<" TouchableTo History: got "<<allSensitiveDets.size()
38  <<" sensitive detectors from TrackerMapDDDtoID.";
39 
40  for ( auto & theSD : allSensitiveDets)
41  {
42  DDTranslation const & t = theSD->translation();
43  theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z()));
44  G4TouchableHistory * hist = theNavigator.CreateTouchableHistory();
46  touchToNavStory(hist, st);
47 
48  myMap[st] = Nav_type(theSD->navType().begin(),theSD->navType().end());
49  myDirectMap[st] = theSD->geographicalID();
50 
51  LogDebug("TrackerSimDebugNumbering")
52  <<" INSERTING LV " <<hist->GetVolume()->GetLogicalVolume()->GetName()
53  <<" SD: "<<hist->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()->GetName()
54  <<" Now size is "<<myDirectMap.size();
55  delete hist;
56  }
57  edm::LogInfo("TrackerSimInfoNumbering")
58  <<" TrackerG4SimHitNumberingScheme: mapped "<<myDirectMap.size()<<" detectors to Geant4.";
59 
60  if (myDirectMap.size() != allSensitiveDets.size()){
61  edm::LogError("TrackerSimInfoNumbering")
62  <<" ERROR: DDD sensitive detectors do not match Geant4 ones.";
63  throw cms::Exception("TrackerG4SimHitNumberingScheme::buildAll")
64  << " cannot resolve structure of tracking sensitive detectors";
65  }
66 }
67 
68 const DDFilteredView&
70  if (alreadySet == false) {
71  buildAll();
72  }
74  touchToNavStory(&t, st);
75  f.goTo(myMap[st]);
76  return f;
77 }
78 
81  if (alreadySet == false) {
82  buildAll();
83  }
85  touchToNavStory(&t, st);
86  return myMap[st];
87 }
88 
91  if (alreadySet == false) {
92  buildAll();
93  }
94 
95  const DDTranslation& t = i.translation();
96 
97  G4Navigator* theStdNavigator =
98  G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
99  G4Navigator theNavigator;
100  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());
101 
102  theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z()));
103  G4TouchableHistory* hist = theNavigator.CreateTouchableHistory();
104  touchToNavStory(hist, st);
105  delete hist;
106 }
107 
110 #ifdef DEBUG
111  std::vector<int> debugint;
112  std::vector<std::string> debugstring;
113 #endif
114  int levels = v->GetHistoryDepth();
115 
116  for (int k=0; k<=levels; ++k){
117  if (v->GetVolume(k)->GetLogicalVolume()->GetName() != "TOBInactive") {
118  st.push_back(std::pair<int,std::string>
119  (v->GetVolume(k)->GetCopyNo(),
120  v->GetVolume(k)->GetLogicalVolume()->GetName()));
121 #ifdef DEBUG
122  debugint.push_back(v->GetVolume(k)->GetCopyNo());
123  debugstring.push_back(v->GetVolume(k)->GetLogicalVolume()->GetName());
124 #endif
125  }
126  }
127 #ifdef DEBUG
128  LogDebug("TrackerSimDebugNumbering")<<" G4 TrackerG4SimHitNumberingScheme "<< debugint;
129  for(u_int32_t jj=0;jj<debugstring.size();jj++)LogDebug("TrackerSimDebugNumbering")<<" "<<debugstring[jj];
130 #endif
131 }
132 
135  if (alreadySet == false) {
136  buildAll();
137  }
138 #ifdef DEBUG
139  dumpG4VPV(v);
140 #endif
142  touchToNavStory(v, st);
143  return myMap[st];
144 }
145 
146 unsigned int TrackerG4SimHitNumberingScheme::g4ToNumberingScheme(const G4VTouchable* v) {
147  if (alreadySet == false) {
148  buildAll();
149  }
151  touchToNavStory(v, st);
152 
153 #ifdef DEBUG
154  dumpG4VPV(v);
155  LogDebug("TrackerSimDebugNumbering")<<" Returning: "<< myDirectMap[st];
156 #endif
157 
158  return myDirectMap[st];
159 }
160 
162  int levels = v->GetHistoryDepth();
163 
164  LogDebug("TrackerSimDebugNumbering")<<" NAME : "<<v->GetVolume()->GetLogicalVolume()->GetName();
165  for (int k=0; k<=levels; k++){
166  LogDebug("TrackerSimInfoNumbering") <<" Hist: "<< v->GetVolume(k)->GetLogicalVolume()->GetName()<<
167  " Copy "<< v->GetVolume(k)->GetCopyNo();
168  }
169 }
170 
#define LogDebug(id)
TrackerG4SimHitNumberingScheme(const DDCompactView &, const GeometricDet &)
Nav_type & touchableToNavType(const G4VTouchable *)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
bool goTo(const nav_type &)
std::vector< std::pair< int, std::string > > Nav_Story
unsigned int g4ToNumberingScheme(const G4VTouchable *)
double f[11][100]
Nav_type & getNavType(const G4VTouchable &)
int k[5][pyjets_maxn]
ConstGeometricDetContainer deepComponents() const
void getNavStory(DDFilteredView &, Nav_Story &)
const DDTranslation & translation() const
The absolute translation of the current node.
const DDFilteredView & getFilteredView(const G4VTouchable &, DDFilteredView &)
void touchToNavStory(const G4VTouchable *, Nav_Story &)