CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

TouchableToHistory Class Reference

#include <TouchableToHistory.h>

List of all members.

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 ()
DDFilteredViewgetFilteredView (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 DDCompactViewmyCompactView
DirectMapType myDirectMap
const GeometricDetmyGeomDet
MapType myMap

Detailed Description

Definition at line 16 of file TouchableToHistory.h.


Member Typedef Documentation

Definition at line 23 of file TouchableToHistory.h.

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.


Constructor & Destructor Documentation

TouchableToHistory::TouchableToHistory ( const DDCompactView cpv,
const GeometricDet det 
) [inline]

Definition at line 24 of file TouchableToHistory.h.

                                                                          : 
         alreadySet(false), myCompactView(&cpv), myGeomDet(&det) {} 

Member Function Documentation

void TouchableToHistory::buildAll ( )

Definition at line 17 of file TouchableToHistory.cc.

References alreadySet, GeometricDet::deepComponents(), estimatePileup::hist, myDirectMap, myGeomDet, myMap, lumiQTWidget::t, and touchableToNavStory().

Referenced by getFilteredView(), getNavStory(), touchableToInt(), and touchableToNavType().

                                 {
  if (alreadySet) return;
  alreadySet = true;

  G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
  G4Navigator theNavigator;
  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());


  std::vector<const GeometricDet*> allSensitiveDets;
  myGeomDet->deepComponents(allSensitiveDets);
  edm::LogInfo("TrackerSimInfoNumbering")<<" TouchableTo History: got "<<allSensitiveDets.size()<<" sensitive detectors from TrackerMapDDDtoID.";

  for ( std::vector<const GeometricDet*>::const_iterator it = allSensitiveDets.begin(); 
        it != allSensitiveDets.end(); 
        ++it)
    {
      DDTranslation const & t = (*it)->translation(); 
      theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z()));
      G4TouchableHistory * hist = theNavigator.CreateTouchableHistory(); 
      TouchableToHistory::Nav_Story st =  touchableToNavStory(hist);

#ifdef DEBUG    
    u_int32_t oldsize = myDirectMap.size();
#endif

    myMap[st] = nav_type((*it)->navType().begin(),(*it)->navType().end());
    myDirectMap[st] = (*it)->geographicalID();

    /*
#ifdef DEBUG    
    LogDebug("TrackerSimDebugNumbering")<< " INSERTING "<<view.logicalPart().name()<<" "<<t<<" "<<hist->GetVolume()->GetLogicalVolume()->GetName();
    LogDebug("TrackerSimDebugNumbering")<<" Sensitive: "<<hist->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()<<std::endl;
    LogDebug("TrackerSimDebugNumbering")<<"Now size is "<<myDirectMap.size()<<std::endl;
    if (oldsize == myDirectMap.size())
      edm::LogError("TrackerSimInfoNumbering")<< "Touchable to History Error!!!!";
    dumpG4VPV(hist);
#endif
    */
    delete hist;

  }
  edm::LogInfo("TrackerSimInfoNumbering")<<" TouchableToHistory: mapped "<<myDirectMap.size()<<" detectors to G4.";

  if (myDirectMap.size() != allSensitiveDets.size()){
    edm::LogError("TrackerSimInfoNumbering")<<" ERROR: DDD sensitive detectors do not match Geant4 ones.";
    //FIXME use throw
    abort();
  }


}
void TouchableToHistory::dumpG4VPV ( const G4VTouchable *  v) [private]

Definition at line 145 of file TouchableToHistory.cc.

References gen::k, and LogDebug.

Referenced by touchableToInt(), and touchableToNavType().

                                                       {
  int levels = v->GetHistoryDepth();
  
  LogDebug("TrackerSimDebugNumbering")<<" NAME : "<<v->GetVolume()->GetLogicalVolume()->GetName();
  for (int k=0; k<=levels; k++){
    LogDebug("TrackerSimInfoNumbering") <<" Hist: "<< v->GetVolume(k)->GetLogicalVolume()->GetName()<<
      " Copy "<< v->GetVolume(k)->GetCopyNo();
  }
}
DDFilteredView & TouchableToHistory::getFilteredView ( const G4VTouchable &  t,
DDFilteredView f 
)

Definition at line 70 of file TouchableToHistory.cc.

References alreadySet, buildAll(), f, DDFilteredView::goTo(), myMap, and touchableToNavStory().

                                                                                           {
  if (alreadySet == false) 
    buildAll();
  f.goTo(myMap[touchableToNavStory(&t)]);
  return f;
}
TouchableToHistory::Nav_Story TouchableToHistory::getNavStory ( DDFilteredView i)

Definition at line 82 of file TouchableToHistory.cc.

References alreadySet, buildAll(), estimatePileup::hist, lumiQTWidget::t, groupFilesInBlocks::temp, touchableToNavStory(), and DDFilteredView::translation().

                                                                            {
  if (alreadySet == false) buildAll();
  DDTranslation t = i.translation();

  G4Navigator* theStdNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
  G4Navigator  theNavigator;
  theNavigator.SetWorldVolume(theStdNavigator->GetWorldVolume());

  theNavigator.LocateGlobalPointAndSetup(G4ThreeVector(t.x(),t.y(),t.z()));
  G4TouchableHistory* hist = theNavigator.CreateTouchableHistory(); 
  TouchableToHistory::Nav_Story temp = touchableToNavStory(hist);
  delete hist;
  return (temp);
}
TouchableToHistory::nav_type TouchableToHistory::getNavType ( const G4VTouchable &  t)

Definition at line 76 of file TouchableToHistory.cc.

References alreadySet, myMap, and touchableToNavStory().

                                                                              {
  if (alreadySet == false) 
    edm::LogError("TrackerSimInfoNumbering")<<" NOT READY ";
  return myMap[touchableToNavStory(&t)];
}
G4VPhysicalVolume& TouchableToHistory::getTouchable ( DDFilteredView )
int TouchableToHistory::touchableToInt ( const G4VTouchable *  v)

Definition at line 134 of file TouchableToHistory.cc.

References alreadySet, buildAll(), dumpG4VPV(), LogDebug, myDirectMap, and touchableToNavStory().

Referenced by TrackerG4SimHitNumberingScheme::g4ToNumberingScheme().

                                                            {
  if (alreadySet == false) 
    buildAll();

  dumpG4VPV(v);

  LogDebug("TrackerSimDebugNumbering")<<" Returning: "<< myDirectMap[touchableToNavStory(v)]<<std::endl;

  return   myDirectMap[touchableToNavStory(v)];
}
TouchableToHistory::Nav_Story TouchableToHistory::touchableToNavStory ( const G4VTouchable *  v)

Definition at line 97 of file TouchableToHistory.cc.

References findQualityFiles::jj, gen::k, LogDebug, and groupFilesInBlocks::temp.

Referenced by buildAll(), getFilteredView(), getNavStory(), getNavType(), touchableToInt(), and touchableToNavType().

                                                                                         {
  static G4String tobinactive("TOBInactive");
  Nav_Story temp;
#ifdef DEBUG    
  std::vector<int> debugint;
  std::vector<std::string> debugstring;
#endif
  int levels = v->GetHistoryDepth();
  
  for (int k=0; k<=levels; k++){
    if (v->GetVolume(k)->GetLogicalVolume()->GetName() != tobinactive) {
      temp.push_back(
                     std::pair<int,std::string>
                     (v->GetVolume(k)->GetCopyNo(),
                      v->GetVolume(k)->GetLogicalVolume()->GetName()));
#ifdef DEBUG    
      debugint.push_back(v->GetVolume(k)->GetCopyNo());
      debugstring.push_back(v->GetVolume(k)->GetLogicalVolume()->GetName());
#endif
    }
  }
#ifdef DEBUG    
  // LogDebug("TrackerSimDebugNumbering")<<" G4 TouchableToHistory "<< debugint;
  for(u_int32_t jj=0;jj<debugstring.size();jj++)LogDebug("TrackerSimDebugNumbering")<<" "<<debugstring[jj];
#endif
  return temp;
}
TouchableToHistory::nav_type TouchableToHistory::touchableToNavType ( const G4VTouchable *  v)

Definition at line 125 of file TouchableToHistory.cc.

References alreadySet, buildAll(), dumpG4VPV(), myMap, and touchableToNavStory().

                                                                                       {
  if (alreadySet == false) 
    buildAll();

  dumpG4VPV(v);

  return   myMap[touchableToNavStory(v)];
}

Member Data Documentation

Definition at line 39 of file TouchableToHistory.h.

Definition at line 37 of file TouchableToHistory.h.

Referenced by buildAll(), and touchableToInt().

Definition at line 40 of file TouchableToHistory.h.

Referenced by buildAll().

Definition at line 36 of file TouchableToHistory.h.

Referenced by buildAll(), getFilteredView(), getNavType(), and touchableToNavType().