test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TouchableToHistory.cc
Go to the documentation of this file.
6 
7 
8 #include "G4TransportationManager.hh"
9 #include "G4Navigator.hh"
10 #include "G4VTouchable.hh"
11 #include "G4TouchableHistory.hh"
12 
14 
15 //#define DEBUG
16 
18  if (alreadySet) return;
19  alreadySet = true;
20 
21  G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
22  G4Navigator theNavigator;
23  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());
24 
25 
26  std::vector<const GeometricDet*> allSensitiveDets;
27  myGeomDet->deepComponents(allSensitiveDets);
28  edm::LogInfo("TrackerSimInfoNumbering")<<" TouchableTo History: got "<<allSensitiveDets.size()<<" sensitive detectors from TrackerMapDDDtoID.";
29 
30  for ( std::vector<const GeometricDet*>::const_iterator it = allSensitiveDets.begin();
31  it != allSensitiveDets.end();
32  ++it)
33  {
34  DDTranslation const & t = (*it)->translation();
35  theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z()));
36  G4TouchableHistory * hist = theNavigator.CreateTouchableHistory();
38 
39 #ifdef DEBUG
40  u_int32_t oldsize = myDirectMap.size();
41 #endif
42 
43  myMap[st] = nav_type((*it)->navType().begin(),(*it)->navType().end());
44  myDirectMap[st] = (*it)->geographicalID();
45 
46  /*
47 #ifdef DEBUG
48  LogDebug("TrackerSimDebugNumbering")<< " INSERTING "<<view.logicalPart().name()<<" "<<t<<" "<<hist->GetVolume()->GetLogicalVolume()->GetName();
49  LogDebug("TrackerSimDebugNumbering")<<" Sensitive: "<<hist->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()<<std::endl;
50  LogDebug("TrackerSimDebugNumbering")<<"Now size is "<<myDirectMap.size()<<std::endl;
51  if (oldsize == myDirectMap.size())
52  edm::LogError("TrackerSimInfoNumbering")<< "Touchable to History Error!!!!";
53  dumpG4VPV(hist);
54 #endif
55  */
56  delete hist;
57 
58  }
59  edm::LogInfo("TrackerSimInfoNumbering")<<" TouchableToHistory: mapped "<<myDirectMap.size()<<" detectors to G4.";
60 
61  if (myDirectMap.size() != allSensitiveDets.size()){
62  edm::LogError("TrackerSimInfoNumbering")<<" ERROR: DDD sensitive detectors do not match Geant4 ones.";
63  //FIXME use throw
64  abort();
65  }
66 
67 
68 }
69 
71  if (alreadySet == false)
72  buildAll();
74  return f;
75 }
77  if (alreadySet == false)
78  edm::LogError("TrackerSimInfoNumbering")<<" NOT READY ";
79  return myMap[touchableToNavStory(&t)];
80 }
81 
83  if (alreadySet == false) buildAll();
85 
86  G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
87  G4Navigator theNavigator;
88  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());
89 
90  theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z()));
91  G4TouchableHistory* hist = theNavigator.CreateTouchableHistory();
93  delete hist;
94  return (temp);
95 }
96 
99 #ifdef DEBUG
100  std::vector<int> debugint;
101  std::vector<std::string> debugstring;
102 #endif
103  int levels = v->GetHistoryDepth();
104 
105  for (int k=0; k<=levels; k++){
106  if (v->GetVolume(k)->GetLogicalVolume()->GetName() != "TOBInactive") {
107  temp.push_back(
108  std::pair<int,std::string>
109  (v->GetVolume(k)->GetCopyNo(),
110  v->GetVolume(k)->GetLogicalVolume()->GetName()));
111 #ifdef DEBUG
112  debugint.push_back(v->GetVolume(k)->GetCopyNo());
113  debugstring.push_back(v->GetVolume(k)->GetLogicalVolume()->GetName());
114 #endif
115  }
116  }
117 #ifdef DEBUG
118  // LogDebug("TrackerSimDebugNumbering")<<" G4 TouchableToHistory "<< debugint;
119  for(u_int32_t jj=0;jj<debugstring.size();jj++)LogDebug("TrackerSimDebugNumbering")<<" "<<debugstring[jj];
120 #endif
121  return temp;
122 }
123 
125  if (alreadySet == false)
126  buildAll();
127 
128  dumpG4VPV(v);
129 
130  return myMap[touchableToNavStory(v)];
131 }
132 
133 int TouchableToHistory::touchableToInt(const G4VTouchable* v) {
134  if (alreadySet == false)
135  buildAll();
136 
137  dumpG4VPV(v);
138 
139  LogDebug("TrackerSimDebugNumbering")<<" Returning: "<< myDirectMap[touchableToNavStory(v)]<<std::endl;
140 
141  return myDirectMap[touchableToNavStory(v)];
142 }
143 
144 void TouchableToHistory::dumpG4VPV(const G4VTouchable* v){
145  int levels = v->GetHistoryDepth();
146 
147  LogDebug("TrackerSimDebugNumbering")<<" NAME : "<<v->GetVolume()->GetLogicalVolume()->GetName();
148  for (int k=0; k<=levels; k++){
149  LogDebug("TrackerSimInfoNumbering") <<" Hist: "<< v->GetVolume(k)->GetLogicalVolume()->GetName()<<
150  " Copy "<< v->GetVolume(k)->GetCopyNo();
151  }
152 }
153 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
DirectMapType myDirectMap
DDFilteredView & getFilteredView(const G4VTouchable &, DDFilteredView &)
nav_type touchableToNavType(const G4VTouchable *)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
bool goTo(const nav_type &)
const GeometricDet * myGeomDet
std::vector< int > nav_type
Nav_Story getNavStory(DDFilteredView &)
Nav_Story touchableToNavStory(const G4VTouchable *)
double f[11][100]
void dumpG4VPV(const G4VTouchable *)
std::vector< std::pair< int, std::string > > Nav_Story
ConstGeometricDetContainer deepComponents() const
nav_type getNavType(const G4VTouchable &)
const DDTranslation & translation() const
The absolute translation of the current node.
int touchableToInt(const G4VTouchable *)