コード例 #1
0
int main() {

  TGeoNode *node =  NULL;
  TGeoVolume *vol = NULL;
  
  LMCgeomN *g = new LMCgeomN("Telescope");
  TObjArray *oa = g->GetGeoManager()->GetListOfNodes();
  for (int i=0; i<oa->GetEntries(); i++) {
    node =  (TGeoNode*)oa->At(i);
    vol = node->GetVolume();
    cout << "= " << node->GetName() << "  " << vol->GetName()  <<endl;
    TObjArray *vnodes = vol->GetNodes();
    cout << vnodes->GetEntries() << endl;
    for (int j=0; j<vnodes->GetEntries(); j++) {
      node = (TGeoNode*)vnodes->At(j);
      cout << "== " << node->GetName() << endl;
      vol = node->GetVolume();
      TObjArray *vnodes1 = vol->GetNodes();
      for (int k=0; k<vnodes1->GetEntries(); k++) {
	node = (TGeoNode*)vnodes1->At(k);
	cout << "=== " << node->GetName() << endl;
	vol = node->GetVolume();
	TObjArray *vnodes2 = vol->GetNodes();
	if(!vnodes2) continue;
	for (int q=0; q<vnodes2->GetEntries(); q++) {
	   node = (TGeoNode*)vnodes2->At(q);
	   cout << "==== " << node->GetName() << endl;
	 }
	
      }
    }
  }

  return 0;
}
コード例 #2
0
ファイル: AlignmentOperators.cpp プロジェクト: vvolkl/DD4hep
template <> void AlignmentActor<DDAlign_standard_operations::node_reset>::operator()(Nodes::value_type& n) const  {
  TGeoPhysicalNode* p = n.second.first;
  //Entry*            e = n.second.second;
  string np;
  if ( p->IsAligned() )   {
    for (Int_t i=0, nLvl=p->GetLevel(); i<=nLvl; i++) {
      TGeoNode* node = p->GetNode(i);
      TGeoMatrix* mm = node->GetMatrix();  // Node's relative matrix
      np += string("/")+node->GetName();
      if ( !mm->IsIdentity() && i > 0 )  {    // Ignore the 'world', is identity anyhow
        GlobalAlignment a = cache.get(np);
        if ( a.isValid() )  {
          printout(ALWAYS,"AlignmentActor<reset>","Correct path:%s leaf:%s",p->GetName(),np.c_str());
          TGeoHMatrix* glob = p->GetMatrix(i-1);
          if ( a.isValid() && i!=nLvl )   {
            *mm = *(a->GetOriginalMatrix());
          }
          else if ( i==nLvl ) {
            TGeoHMatrix* hm = dynamic_cast<TGeoHMatrix*>(mm);
            TGeoMatrix*  org = p->GetOriginalMatrix();
            hm->SetTranslation(org->GetTranslation());
            hm->SetRotation(org->GetRotationMatrix());
          }
          *glob *= *mm;
        }
      }
    }
  }
}
コード例 #3
0
ファイル: DetUtils.cpp プロジェクト: clementhelsens/FCCSW
unsigned int countPlacedVolumes(TGeoVolume* aHighestVolume, const std::string& aMatchName) {
  int numberOfPlacedVolumes = 0;
  TGeoNode* node;
  TGeoIterator next(aHighestVolume);
  while ((node = next())) {
    std::string currentNodeName = node->GetName();
    if (currentNodeName.find(aMatchName) != std::string::npos) {
      ++numberOfPlacedVolumes;
    }
  }
  return numberOfPlacedVolumes;
}
コード例 #4
0
ファイル: Display.cpp プロジェクト: vvolkl/fcc2dd4vis
/// 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();
  }
}
コード例 #5
0
ファイル: dunedphase10kt_geo.C プロジェクト: jhugon/dunetpc
dunedphase10kt_geo(TString volName="")
{
  gSystem->Load("libGeom");
  gSystem->Load("libGdml");

  std::string geofile = "dunedphase10kt_v2.gdml";
  TGeoManager::Import(geofile.c_str());
  
  //TList* mat = gGeoManager->GetListOfMaterials();
  //TIter next(mat);
  
  TGeoIterator next(gGeoManager->GetTopVolume());
  TGeoNode *node = 0;

  //gGeoManager->GetVolume("volCryostat")->SetLineColor(kMagenta);
  //gGeoManager->GetVolume("volCryostat")->SetVisibility(1);
  //gGeoManager->GetVolume("volCryostat")->SetTransparency(85);
  gGeoManager->GetVolume("volSteelShell")->SetLineColor(19);
  gGeoManager->GetVolume("volSteelShell")->SetVisibility(1);
  gGeoManager->GetVolume("volSteelShell")->SetTransparency(85);
    
  gGeoManager->GetVolume("volGaseousArgon")->SetLineColor(kYellow);
  gGeoManager->GetVolume("volGaseousArgon")->SetVisibility(1);
  gGeoManager->GetVolume("volGaseousArgon")->SetTransparency(85);

  while ( (node=(TGeoNode*)next()) ){
    const char* nm = node->GetName();
    
    if( (strncmp(nm, "volCathode", 10) == 0) ){
      node->GetVolume()->SetLineColor(kOrange+3); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(30);
    }
    if( (strncmp(nm, "volTPCActive", 12) == 0) ){
      node->GetVolume()->SetLineColor(kGreen-7); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(80);
    }
    if( (strncmp(nm, "volAPAFrame", 11) == 0) ){
      node->GetVolume()->SetLineColor(kGray); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(20);
    }
    if( (strncmp(nm, "volG10Board", 11) == 0) ){
      node->GetVolume()->SetLineColor(kMagenta-10); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(40);
    }
    if( (strncmp(nm, "volTPCPlane", 11) == 0) ){
      node->GetVolume()->SetLineColor(kBlue-9); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(50);
    }
    if( (strncmp(nm, "volTPCInner", 11) == 0) ){
      node->GetVolume()->SetLineColor(kWhite); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(100);
    }
    if( (strncmp(nm, "volTPCOuter", 11) == 0) ){
      node->GetVolume()->SetLineColor(kWhite); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(100);
    }
    if( (strncmp(nm, "volOpDetSensitive", 17) == 0) ){
      node->GetVolume()->SetLineColor(kRed-4); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(10);
    }
    if( (strncmp(nm, "volWorld", 8) == 0) ){
      node->GetVolume()->SetLineColor(kOrange-7); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(100);
    }
    if( (strncmp(nm, "volFoamPadding", 14) == 0) ){
      node->GetVolume()->SetLineColor(kCyan); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(85);
    }
    if( (strncmp(nm, "volSteelSupport", 15) == 0) ){
      node->GetVolume()->SetLineColor(kBlue); 
      node->GetVolume()->SetVisibility(1);
      node->GetVolume()->SetTransparency(85);
    }
    
  }
  
  gGeoManager->GetTopNode();
  //gGeoManager->CheckOverlaps(1e-5);
  //gGeoManager->PrintOverlaps();
  //gGeoManager->SetMaxVisNodes(70000);

  //gGeoManager->GetTopVolume()->Draw("ogl");
  gGeoManager->FindVolumeFast("volWorld")->Draw("ogl");
  //gGeoManager->FindVolumeFast("volTPCPlaneUInner")->Draw("ogl");
  //if ( ! volName.IsNull() ) gGeoManager->FindVolumeFast(volName)->Draw("ogl");
  //gGeoManager->FindVolumeFast("volCryostat")->Draw("X3D");

  size_t lastindex = geofile.find_last_of(".");
  std::string basename = geofile.substr(0, lastindex);
  
  TFile *tf = new TFile(Form("%s.root",basename.c_str()), "RECREATE");
  gGeoManager->Write();
  tf->Close();
}