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 
98  static G4String tobinactive("TOBInactive");
100 #ifdef DEBUG
101  std::vector<int> debugint;
102  std::vector<std::string> debugstring;
103 #endif
104  int levels = v->GetHistoryDepth();
105 
106  for (int k=0; k<=levels; k++){
107  if (v->GetVolume(k)->GetLogicalVolume()->GetName() != tobinactive) {
108  temp.push_back(
109  std::pair<int,std::string>
110  (v->GetVolume(k)->GetCopyNo(),
111  v->GetVolume(k)->GetLogicalVolume()->GetName()));
112 #ifdef DEBUG
113  debugint.push_back(v->GetVolume(k)->GetCopyNo());
114  debugstring.push_back(v->GetVolume(k)->GetLogicalVolume()->GetName());
115 #endif
116  }
117  }
118 #ifdef DEBUG
119  // LogDebug("TrackerSimDebugNumbering")<<" G4 TouchableToHistory "<< debugint;
120  for(u_int32_t jj=0;jj<debugstring.size();jj++)LogDebug("TrackerSimDebugNumbering")<<" "<<debugstring[jj];
121 #endif
122  return temp;
123 }
124 
126  if (alreadySet == false)
127  buildAll();
128 
129  dumpG4VPV(v);
130 
131  return myMap[touchableToNavStory(v)];
132 }
133 
134 int TouchableToHistory::touchableToInt(const G4VTouchable* v) {
135  if (alreadySet == false)
136  buildAll();
137 
138  dumpG4VPV(v);
139 
140  LogDebug("TrackerSimDebugNumbering")<<" Returning: "<< myDirectMap[touchableToNavStory(v)]<<std::endl;
141 
142  return myDirectMap[touchableToNavStory(v)];
143 }
144 
145 void TouchableToHistory::dumpG4VPV(const G4VTouchable* v){
146  int levels = v->GetHistoryDepth();
147 
148  LogDebug("TrackerSimDebugNumbering")<<" NAME : "<<v->GetVolume()->GetLogicalVolume()->GetName();
149  for (int k=0; k<=levels; k++){
150  LogDebug("TrackerSimInfoNumbering") <<" Hist: "<< v->GetVolume(k)->GetLogicalVolume()->GetName()<<
151  " Copy "<< v->GetVolume(k)->GetCopyNo();
152  }
153 }
154 
#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]
int k[5][pyjets_maxn]
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.
mathSSE::Vec4< T > v
int touchableToInt(const G4VTouchable *)