Exemplo n.º 1
0
 static long dump(DetElement de,int level, bool sensitive_only) {
   const DetElement::Children& c = de.children();
   if ( !sensitive_only || 0 != de.volumeID() )  {
     PlacedVolume place = de.placement();
     const TGeoNode* node = place.ptr();
     char sens = place.volume().isSensitive() ? 'S' : ' ';
     int value = flag;
     char fmt[128];
     switch(value)  {
     case 0:
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X Place:%%p  %%c",level+1,2*level+1);
       printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(c.size()),
                (unsigned long)de.volumeID(), (void*)node, sens);
       break;
     case 1:
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Detector: %%s #Dau:%%d VolID:%%p",level+1,2*level+1);
       printout(INFO,"DetectorDump", fmt, "", de.path().c_str(),
                int(c.size()), (void*)de.volumeID());
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Placement: %%s   %%c",level+1,2*level+3);
       printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(), sens);
       break;
     default:
       break;
     }
   }
   for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i)
     dump((*i).second,level+1,sensitive_only);
   return 1;
 }
Exemplo n.º 2
0
 /// Dump method.
 virtual int operator()(DetElement de,int level)  const  {
   const DetElement::Children& children = de.children();
   PlacedVolume place = de.placement();
   char sens = place.volume().isSensitive() ? 'S' : ' ';
   char fmt[128], tmp[32];
   ::snprintf(tmp,sizeof(tmp),"%03d/",level+1);
   ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X %%c",level+1,2*level+1);
   printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()),
            (unsigned long)de.volumeID(), sens);
   printer.prefix = string(tmp)+de.name();
   (printer)(de, level);
   return 1;
 }
Exemplo n.º 3
0
/// Given a detector element, access it's sensitive detector (if the sub-detector is sensitive!)
SensitiveDetector LCDDHelper::sensitiveDetector(DetElement detector) const    {
  for(DetElement par = detector; par.isValid(); par = par.parent())  {
    if ( par.ptr() != ptr()->world().ptr() )  {
      PlacedVolume pv = par.placement();
      if ( pv.isValid() )   {
        const PlacedVolume::VolIDs& ids = pv.volIDs();
        for(PlacedVolume::VolIDs::const_iterator i=ids.begin(); i!=ids.end();++i)  {
          if ( (*i).first == "system" )   {
            return sensitiveDetector(par.name());
          }
        }
      }
    }
  }
  return SensitiveDetector(0);
}
Exemplo n.º 4
0
/// Load 'levels' Children into the geometry scene
void Display::LoadGeoChildren(TEveElement* start, int levels, bool redraw)  {
  using namespace DD4hep::Geometry;
  DetElement world = m_lcdd->world();
  if ( world.children().size() == 0 )   {
    MessageBox(INFO,"It looks like there is no\nGeometry loaded.\nNo event display availible.\n");
  }
  else if ( levels > 0 )   {
    if ( 0 == start )     {
      TEveElementList& sens = GetGeoTopic("Sensitive");
      TEveElementList& struc = GetGeoTopic("Structure");
      const DetElement::Children& c = world.children();
      
      printout(INFO,"Display","+++ Load children of %s to %d levels", 
               world.placement().name(), levels);
      for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i) {
        DetElement de = (*i).second;
        SensitiveDetector sd = m_lcdd->sensitiveDetector(de.name());
        TEveElementList& parent = sd.isValid() ? sens : struc;
        pair<bool,TEveElement*> e = Utilities::LoadDetElement(de,levels,&parent);
        if ( e.second && e.first )  {
          parent.AddElement(e.second);
        }
      }
    }
    else    {
      TGeoNode* n = (TGeoNode*)start->GetUserData();
      printout(INFO,"Display","+++ Load children of %s to %d levels",Utilities::GetName(start),levels);
      if ( 0 != n )   {
        TGeoHMatrix mat;
        const char* node_name = n->GetName();
        int level = Utilities::findNodeWithMatrix(lcdd().world().placement().ptr(),n,&mat);
        if ( level > 0 )   {
          pair<bool,TEveElement*> e(false,0);
          const DetElement::Children& c = world.children();
          for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i) {
            DetElement de = (*i).second;
            if ( de.placement().ptr() == n )  {
              e = Utilities::createEveShape(0, levels, start, n, mat, de.name());
              break;
            }
          }
          if ( !e.first && !e.second )  {
            e = Utilities::createEveShape(0, levels, start, n, mat, node_name);
          }
          if ( e.first )  { // newly created
            start->AddElement(e.second);
          }
          printout(INFO,"Display","+++ Import geometry node %s with %d levels.",node_name, levels);
        }
        else   {
          printout(INFO,"Display","+++ FAILED to import geometry node %s with %d levels.",node_name, levels);
        }
      }
      else  {
        LoadGeoChildren(0,levels,false);
      }
    }
  }
  if ( redraw )   {
    manager().Redraw3D();
  }
}
Exemplo n.º 5
0
int BoxTrafos()  {
  string xml = "file:";
  xml += gSystem->Getenv("DD4hepINSTALL");
  xml += "/examples/ClientTests/compact/BoxTrafos.xml";
  const char* argv[] = {xml.c_str(), "BUILD_DEFAULT", 0};

  gSystem->Load("libDDCore");
  LCDD& lcdd = LCDD::getInstance();
  lcdd.apply("DD4hepCompactLoader",2,(char**)argv);
  lcdd.apply("DD4hepGeometryDisplay",0,0);


  DetElement de = lcdd.detector("B3");
  PlacedVolume pv = de.placement();
  Volume vol = pv.volume();
  Solid solid = vol.solid();
  TGeoBBox* box = (TGeoBBox*)(solid.ptr());
  Position glob,loc, pos(-10,30,10);

  printf("\n++++  local->world:\n\n");

  loc = Position(-pos.x(),-pos.y(),-pos.z());
  local_to_world("origine",de,pos,loc);

  loc = Position();
  local_to_world("center",de,pos,loc);

  loc = Position(box->GetDX(),box->GetDY(),box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(box->GetDX(),box->GetDY(),-box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(-box->GetDX(),box->GetDY(),box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(-box->GetDX(),box->GetDY(),-box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(box->GetDX(),-box->GetDY(),box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  loc = Position(box->GetDX(),-box->GetDY(),-box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  loc = Position(-box->GetDX(),-box->GetDY(),box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  loc = Position(-box->GetDX(),-box->GetDY(),-box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  printf("\n++++  world->local:\n\n");

  glob = Position(0,0,0);
  world_to_local("world center",de,pos,glob);

  glob = Position(pos.x(),pos.y(),pos.z());
  world_to_local("position",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(),  box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(),  box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(),  box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(),  box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(), -box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(), -box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(), -box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(), -box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  return 1;
}