![]() |
![]() |
#include <SimG4CMS/Tracker/interface/TouchableToHistory.h>
Public Types | |
typedef std::map< Nav_Story, int > | DirectMapType |
typedef std::map< Nav_Story, nav_type > | MapType |
typedef std::vector< std::pair < int, std::string > > | Nav_Story |
typedef std::vector< int > | nav_type |
Public Member Functions | |
void | buildAll () |
DDFilteredView & | getFilteredView (const G4VTouchable &, DDFilteredView &) |
Nav_Story | getNavStory (DDFilteredView &) |
nav_type | getNavType (const G4VTouchable &) |
G4VPhysicalVolume & | getTouchable (DDFilteredView &) |
TouchableToHistory (const DDCompactView &cpv, const GeometricDet &det) | |
int | touchableToInt (const G4VTouchable *) |
Nav_Story | touchableToNavStory (const G4VTouchable *) |
nav_type | touchableToNavType (const G4VTouchable *) |
Private Member Functions | |
void | dumpG4VPV (const G4VTouchable *) |
Private Attributes | |
bool | alreadySet |
const DDCompactView * | myCompactView |
DirectMapType | myDirectMap |
const GeometricDet * | myGeomDet |
MapType | myMap |
Definition at line 16 of file TouchableToHistory.h.
typedef std::map<Nav_Story,int> TouchableToHistory::DirectMapType |
Definition at line 23 of file TouchableToHistory.h.
typedef std::map<Nav_Story,nav_type> TouchableToHistory::MapType |
Definition at line 22 of file TouchableToHistory.h.
typedef std::vector<std::pair<int,std::string> > TouchableToHistory::Nav_Story |
Definition at line 21 of file TouchableToHistory.h.
typedef std::vector<int> TouchableToHistory::nav_type |
Definition at line 20 of file TouchableToHistory.h.
TouchableToHistory::TouchableToHistory | ( | const DDCompactView & | cpv, | |
const GeometricDet & | det | |||
) | [inline] |
Definition at line 24 of file TouchableToHistory.h.
00024 : 00025 alreadySet(false), myCompactView(&cpv), myGeomDet(&det) {}
void TouchableToHistory::buildAll | ( | ) |
Definition at line 22 of file TouchableToHistory.cc.
References TrackerMapDDDtoID::allNavTypes(), alreadySet, DDExpandedView::goTo(), TrackerMapDDDtoID::id(), it, myCompactView, myDirectMap, myGeomDet, myMap, st, t, touchableToNavStory(), and DDExpandedView::translation().
Referenced by getFilteredView(), getNavStory(), touchableToInt(), and touchableToNavType().
00022 { 00023 if (alreadySet == true) return; 00024 alreadySet = true; 00025 00026 TrackerMapDDDtoID dddToID(myGeomDet); 00027 std::vector<nav_type> allSensitiveDets = dddToID.allNavTypes(); 00028 edm::LogInfo("TrackerSimInfoNumbering")<<" TouchableTo History: got "<<allSensitiveDets.size()<<" sensitive detectors from TrackerMapDDDtoID."; 00029 //DDCompactView cv; 00030 DDExpandedView view(*myCompactView); 00031 G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); 00032 G4Navigator* theNavigator = new G4Navigator(); 00033 theNavigator->SetWorldVolume(theStdNavigator->GetWorldVolume()); 00034 00035 for (std::vector<nav_type>::iterator it = allSensitiveDets.begin(); it != allSensitiveDets.end(); it++){ 00036 view.goTo(*it); 00037 DDTranslation t =view.translation(); 00038 theNavigator->LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z())); 00039 G4TouchableHistory * hist = theNavigator->CreateTouchableHistory(); 00040 TouchableToHistory::Nav_Story st = touchableToNavStory(hist); 00041 00042 #ifdef DEBUG 00043 u_int32_t oldsize = myDirectMap.size(); 00044 #endif 00045 00046 myMap[st] = *it; 00047 myDirectMap[st] = dddToID.id(*it); 00048 00049 /* 00050 #ifdef DEBUG 00051 LogDebug("TrackerSimDebugNumbering")<< " INSERTING "<<view.logicalPart().name()<<" "<<t<<" "<<hist->GetVolume()->GetLogicalVolume()->GetName(); 00052 LogDebug("TrackerSimDebugNumbering")<<" Sensitive: "<<hist->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()<<std::endl; 00053 LogDebug("TrackerSimDebugNumbering")<<"Now size is "<<myDirectMap.size()<<std::endl; 00054 if (oldsize == myDirectMap.size()) 00055 edm::LogError("TrackerSimInfoNumbering")<< "Touchable to History Error!!!!"; 00056 dumpG4VPV(hist); 00057 #endif 00058 */ 00059 delete hist; 00060 00061 } 00062 edm::LogInfo("TrackerSimInfoNumbering")<<" TouchableToHistory: mapped "<<myDirectMap.size()<<" detectors to G4."; 00063 00064 if (myDirectMap.size() != allSensitiveDets.size()){ 00065 edm::LogError("TrackerSimInfoNumbering")<<" ERROR: DDD sensitive detectors do not match Geant4 ones."; 00066 abort(); 00067 } 00068 00069 delete theNavigator; 00070 00071 }
void TouchableToHistory::dumpG4VPV | ( | const G4VTouchable * | v | ) | [private] |
Definition at line 146 of file TouchableToHistory.cc.
Referenced by touchableToInt(), and touchableToNavType().
00146 { 00147 int levels = v->GetHistoryDepth(); 00148 00149 for (int k=0; k<=levels; k++){ 00150 LogDebug("TrackerSimInfoNumbering") <<" Hist: "<< v->GetVolume(k)->GetLogicalVolume()->GetName()<< 00151 " Copy "<< v->GetVolume(k)->GetCopyNo(); 00152 } 00153 }
DDFilteredView & TouchableToHistory::getFilteredView | ( | const G4VTouchable & | t, | |
DDFilteredView & | f | |||
) |
Definition at line 73 of file TouchableToHistory.cc.
References alreadySet, buildAll(), DDFilteredView::goTo(), myMap, and touchableToNavStory().
00073 { 00074 if (alreadySet == false) 00075 buildAll(); 00076 f.goTo(myMap[touchableToNavStory(&t)]); 00077 return f; 00078 }
TouchableToHistory::Nav_Story TouchableToHistory::getNavStory | ( | DDFilteredView & | i | ) |
Definition at line 85 of file TouchableToHistory.cc.
References alreadySet, buildAll(), t, pyDBSRunClass::temp, touchableToNavStory(), and DDFilteredView::translation().
00085 { 00086 if (alreadySet == false) buildAll(); 00087 DDTranslation t = i.translation(); 00088 00089 G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); 00090 G4Navigator* theNavigator = new G4Navigator(); 00091 theNavigator->SetWorldVolume(theStdNavigator->GetWorldVolume()); 00092 00093 theNavigator->LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z())); 00094 G4TouchableHistory* hist = theNavigator->CreateTouchableHistory(); 00095 TouchableToHistory::Nav_Story temp = touchableToNavStory(hist); 00096 delete hist; 00097 delete theNavigator; 00098 return (temp); 00099 }
TouchableToHistory::nav_type TouchableToHistory::getNavType | ( | const G4VTouchable & | t | ) |
Definition at line 79 of file TouchableToHistory.cc.
References alreadySet, myMap, and touchableToNavStory().
00079 { 00080 if (alreadySet == false) 00081 edm::LogError("TrackerSimInfoNumbering")<<" NOT READY "; 00082 return myMap[touchableToNavStory(&t)]; 00083 }
G4VPhysicalVolume& TouchableToHistory::getTouchable | ( | DDFilteredView & | ) |
int TouchableToHistory::touchableToInt | ( | const G4VTouchable * | v | ) |
Definition at line 136 of file TouchableToHistory.cc.
References alreadySet, buildAll(), dumpG4VPV(), lat::endl(), LogDebug, myDirectMap, and touchableToNavStory().
Referenced by TrackerG4SimHitNumberingScheme::g4ToNumberingScheme().
00136 { 00137 if (alreadySet == false) 00138 buildAll(); 00139 LogDebug("TrackerSimDebugNumbering")<<" NAME : "<<v->GetVolume()->GetLogicalVolume()->GetName(); 00140 dumpG4VPV(v); 00141 LogDebug("TrackerSimDebugNumbering")<<" Returning: "<< myDirectMap[touchableToNavStory(v)]<<std::endl; 00142 00143 return myDirectMap[touchableToNavStory(v)]; 00144 }
TouchableToHistory::Nav_Story TouchableToHistory::touchableToNavStory | ( | const G4VTouchable * | v | ) |
Definition at line 101 of file TouchableToHistory.cc.
References k, LogDebug, and pyDBSRunClass::temp.
Referenced by buildAll(), getFilteredView(), getNavStory(), getNavType(), touchableToInt(), and touchableToNavType().
00101 { 00102 static G4String tobinactive("TOBInactive"); 00103 Nav_Story temp; 00104 #ifdef DEBUG 00105 std::vector<int> debugint; 00106 std::vector<std::string> debugstring; 00107 #endif 00108 int levels = v->GetHistoryDepth(); 00109 00110 for (int k=0; k<=levels; k++){ 00111 if (v->GetVolume(k)->GetLogicalVolume()->GetName() != tobinactive) { 00112 temp.push_back( 00113 std::pair<int,std::string> 00114 (v->GetVolume(k)->GetCopyNo(), 00115 v->GetVolume(k)->GetLogicalVolume()->GetName())); 00116 #ifdef DEBUG 00117 debugint.push_back(v->GetVolume(k)->GetCopyNo()); 00118 debugstring.push_back(v->GetVolume(k)->GetLogicalVolume()->GetName()); 00119 #endif 00120 } 00121 } 00122 #ifdef DEBUG 00123 // LogDebug("TrackerSimDebugNumbering")<<" G4 TouchableToHistory "<< debugint; 00124 for(u_int32_t jj=0;jj<debugstring.size();jj++)LogDebug("TrackerSimDebugNumbering")<<" "<<debugstring[jj]; 00125 #endif 00126 return temp; 00127 }
TouchableToHistory::nav_type TouchableToHistory::touchableToNavType | ( | const G4VTouchable * | v | ) |
Definition at line 129 of file TouchableToHistory.cc.
References alreadySet, buildAll(), dumpG4VPV(), LogDebug, myMap, and touchableToNavStory().
00129 { 00130 if (alreadySet == false) 00131 buildAll(); 00132 LogDebug("TrackerSimDebugNumbering")<<" NAME : "<<v->GetVolume()->GetLogicalVolume()->GetName(); 00133 dumpG4VPV(v); 00134 return myMap[touchableToNavStory(v)]; 00135 }
bool TouchableToHistory::alreadySet [private] |
Definition at line 38 of file TouchableToHistory.h.
Referenced by buildAll(), getFilteredView(), getNavStory(), getNavType(), touchableToInt(), and touchableToNavType().
const DDCompactView* TouchableToHistory::myCompactView [private] |
DirectMapType TouchableToHistory::myDirectMap [private] |
const GeometricDet* TouchableToHistory::myGeomDet [private] |
MapType TouchableToHistory::myMap [private] |
Definition at line 36 of file TouchableToHistory.h.
Referenced by buildAll(), getFilteredView(), getNavType(), and touchableToNavType().