当前位置: 首页>>代码示例>>C++>>正文


C++ TGeoVolume::GetMaterial方法代码示例

本文整理汇总了C++中TGeoVolume::GetMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoVolume::GetMaterial方法的具体用法?C++ TGeoVolume::GetMaterial怎么用?C++ TGeoVolume::GetMaterial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TGeoVolume的用法示例。


在下文中一共展示了TGeoVolume::GetMaterial方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateVolumeAndNodeNames

void KVSpectroDetector::UpdateVolumeAndNodeNames(){
	// Update the names of Volumes and the names of the Nodes of this
	// detector.
	// The name of the volume representing the detector (returned
	// by GetAbsGeoVolume()) is DET_<detector name>. 
	// The name of the active volumes is ACTIVE_<detector name>_<material name>.
	// The name of the other volumes is <detector name>_<material name>.

	GetAbsGeoVolume()->SetName( Form("DET_%s", GetName() ) );
	TObjArray  *nodes = GetAbsGeoVolume()->GetNodes();
	TGeoNode   *node  = NULL;
	TGeoVolume *vol   = NULL;

	TIter next( nodes );
	while( (node = (TGeoNode *)next()) ){
		TString name, nname;
		vol = node->GetVolume();
		name.Form("%s_%s", GetName(), vol->GetMaterial()->GetName());
		if( GetActiveVolumes()->Contains( vol ) )
			name.Prepend("ACTIVE_");
		vol->SetName( name.Data() );
		nname = name;
		Int_t i=0;
		while( nodes->FindObject( nname.Data() ) )
			nname.Form("%s_%d",name.Data(), ++i);
		node->SetName( nname.Data() );
		node->SetNumber( i );
	}
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:29,代码来源:KVSpectroDetector.cpp

示例2: fw_simGeo_set_volume_color_by_material

void fw_simGeo_set_volume_color_by_material(const char* material_re, Bool_t use_names, Color_t color, Char_t transparency=-1)
{
   // Note: material_re is a perl regexp!
   // If you want exact match, enclose in begin / end meta characters (^ / $):
   //   set_volume_color_by_material("^materials:Silicon$", kRed);

   TPMERegexp re(material_re, "o");
   TGeoMaterial *m;
   TIter it(FWGeometryTableViewManager_GetGeoManager()->GetListOfMaterials());
   while ((m = (TGeoMaterial*) it()) != 0)
   {
      if (re.Match(use_names ? m->GetName() : m->GetTitle()))
      {
         if (transparency != -1)
         {
            m->SetTransparency(transparency);
         }
         TGeoVolume *v;
         TIter it2(FWGeometryTableViewManager_GetGeoManager()->GetListOfVolumes());
         while ((v = (TGeoVolume*) it2()) != 0)
         {
            if (v->GetMaterial() == m)
            {
               v->SetLineColor(color);
            }
         }
      }
   }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:29,代码来源:fw_simGeo_foos.C

示例3: set_volume_color_by_material

void set_volume_color_by_material(const char* material_re, Color_t color, Char_t transparency=-1)
{
   // Note: material_re is a perl regexp!
   // If you want exact match, enclose in begin / end meta characters (^ / $):
   //   set_volume_color_by_material("^materials:Silicon$", kRed);

   TPMERegexp re(material_re, "o");
   TGeoMaterial *m;
   TIter it(gGeoManager->GetListOfMaterials());
   while ((m = (TGeoMaterial*) it()) != 0)
   {
      if (re.Match(m->GetName()))
      {
         if (transparency != -1)
         {
            m->SetTransparency(transparency);
         }
         TGeoVolume *v;
         TIter it2(gGeoManager->GetListOfVolumes());
         while ((v = (TGeoVolume*) it2()) != 0)
         {
            if (v->GetMaterial() == m)
            {
               v->SetLineColor(color);
            }
         }
      }
   }
   full_update();
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:30,代码来源:common_foos.C

示例4: visibility_volume_by_material

void visibility_volume_by_material(const char* material_re, Bool_t vis_state)
{
   TPMERegexp re(material_re, "o");
   TGeoMaterial *m;
   TIter it(gGeoManager->GetListOfMaterials());
   while ((m = (TGeoMaterial*) it()) != 0)
   {
      if (re.Match(m->GetName()))
      {
         TGeoVolume *v;
         TIter it2(gGeoManager->GetListOfVolumes());
         while ((v = (TGeoVolume*) it2()) != 0)
         {
            if (v->GetMaterial() == m)
            {
               v->SetVisibility(vis_state);
            }
         }
      }
   }
   full_update();
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:22,代码来源:common_foos.C

示例5: m

drawFGT(TString volName="")
{
  gSystem->Load("libGeom");
  gSystem->Load("libGdml");

  TGeoManager::Import("fgt.gdml");
  gGeoManager->DefaultColors();

  bool allSolid=true;
  
  char topVol[] ="volWorld";
  //char topVol[] ="volDetEnclosure";
  //char topVol[] ="volDetector";

  //char topVol[] ="volMuIDDownstream";
  //char topVol[] ="volMuIDBarrel";
  //char topVol[] ="volRPCMod";
  //char topVol[] ="volRPCTray_End";

  //char topVol[] ="volECALDownstream";
  //char topVol[] ="volECALUpstream";
  //char topVol[] ="volBarrelECAL";
  //char topVol[] ="volSBPlane";

  //char topVol[] ="volSTT";
  //char topVol[] ="volSTPlaneTarget";
  //char topVol[] ="volSTPlaneRadiator";
  //char topVol[] ="volTargetPlaneArgon";


  gGeoManager->GetVolume("volDetEnclosure")->SetLineColor(kGray);
  gGeoManager->GetVolume("volDetEnclosure")->SetVisibility(1);
  gGeoManager->GetVolume("volDetEnclosure")->SetTransparency(20);

  gGeoManager->GetVolume("volDirtLayer")->SetTransparency(20);

  gGeoManager->GetVolume("volServiceBuilding")->SetLineColor(kGray);
  gGeoManager->GetVolume("volServiceBuilding")->SetVisibility(1);
  gGeoManager->GetVolume("volServiceBuilding")->SetTransparency(20);


  gGeoManager->GetVolume("volSky")->SetLineColor(kWhite);
  gGeoManager->GetVolume("volSky")->SetVisibility(1);
  gGeoManager->GetVolume("volSky")->SetTransparency(20);


  gGeoManager->GetVolume("volMagnet")->SetLineColor(kGreen-1);
  gGeoManager->GetVolume("volMagnet")->SetVisibility(1);
  if(!allSolid) gGeoManager->GetVolume("volMagnet")->SetTransparency(10);


  gGeoManager->GetVolume("volECALBarrelMod")->SetLineColor(kRed);
  gGeoManager->GetVolume("volECALBarrelMod")->SetVisibility(1);
  if(!allSolid) gGeoManager->GetVolume("volECALBarrelMod")->SetTransparency(75);
  
  gGeoManager->GetVolume("volSBPlane")->SetLineColor(kRed-3);
  gGeoManager->GetVolume("volSBPlane")->SetVisibility(1);
  if(!allSolid) gGeoManager->GetVolume("volSBPlane")->SetTransparency(80);
  /*
  gGeoManager->GetVolume("volECALUpstream")->SetLineColor(kYellow-3);
  gGeoManager->GetVolume("volECALUpstream")->SetVisibility(1);
  gGeoManager->GetVolume("volECALUpstream")->SetTransparency(20);
  gGeoManager->GetVolume("volECALDownstream")->SetLineColor(kYellow-3);
  gGeoManager->GetVolume("volECALDownstream")->SetVisibility(1);
  gGeoManager->GetVolume("volECALDownstream")->SetTransparency(20);
  */
  
  TObjArray* va = gGeoManager->GetListOfVolumes();
  int nv = va->GetEntries();
  for (int i=0; i<nv; ++i) {
    TGeoVolume* v = (TGeoVolume*)va->At(i);
    std::string m(v->GetMaterial()->GetName());
    //cout << v->GetMaterial()->GetName() << endl;
    int lc, vi, tr, vd;
    if           (m == "Scintillator")             { 
      lc = kGreen-7 ; vi = 1; tr = 0; vd = 1; 
      v->SetLineColor(lc);
      v->SetVisibility(vi);
      v->VisibleDaughters(vd);
      v->SetTransparency(tr);
    }
    //else {
    //  continue;
      //std::cout << "'" << m << "' has no defaults" << std::endl;
      //lc = kOrange; vi = 0; tr = 50; vd = 1; 
    //}

  }
  

 //gGeoManager->GetTopNode();
 gGeoManager->CheckOverlaps(1e-5,"d");
 gGeoManager->PrintOverlaps();
 //gGeoManager->FindVolumeFast(topVol)->CheckOverlaps(1e-5,"d");
 //gGeoManager->FindVolumeFast(topVol)->GetNode(0)->PrintOverlaps();
 gGeoManager->SetMaxVisNodes(70000);


 gGeoManager->FindVolumeFast(topVol)->Draw("ogl");

//.........这里部分代码省略.........
开发者ID:sinclairjr,项目名称:duneggd,代码行数:101,代码来源:drawFGT.C

示例6: get_mass

//____________________________________________________________________________
void get_mass(Double_t length_unit, Double_t density_unit)
{
   //tables of Z and A
   const Int_t lcin_Z = 150;
   const Int_t lcin_A = 300;

   // calc unit conversion factors
   Double_t density_unit_to_SI = density_unit / units::kg_m3;
   Double_t length_unit_to_SI  = length_unit  / units::m;
   Double_t volume_unit_to_SI  = TMath::Power(length_unit_to_SI, 3.);
#ifdef _debug_
   cout << "Input density unit --> kg/m^3 : x" << density_unit_to_SI << endl;
   cout << "Input length  unit --> m      : x" << length_unit_to_SI  << endl;
#endif

   // get materials in geometry
   TList *matlist = gGeoManager->GetListOfMaterials();
   if (!matlist ) { 
     cout << "Null list of materials!" << endl; 
     return; 
   } else {
#ifdef _debug_
     matlist->Print();
#endif
   }

   int max_idx = 0; // number of mixtures in geometry
   Int_t nmat = matlist->GetEntries();
   for( Int_t imat = 0; imat < nmat; imat++ )
   {
      Int_t idx = gGeoManager->GetMaterial(imat)->GetIndex();
      max_idx = TMath::Max(max_idx, idx);
   }

   //check if material index is unique
   Int_t * checkindex = new Int_t[max_idx+1];
   for( Int_t i = 0; i<max_idx+1; i++ ) checkindex[i] = 0;
   for( Int_t imat = 0; imat < nmat; imat++ )
   {
      if( !checkindex[imat] ) checkindex[imat] = 1;
      else 
      {
         cout << "material index is not unique" << endl;
        return;
      }
   }

#ifdef _debug_
   cout << "max_idx = " << max_idx << endl;
   cout << "nmat    = " << nmat    << endl;
#endif

   TGeoVolume * topvol = gGeoManager->GetTopVolume(); //get top volume
   if (!topvol) {
     cout << "volume does not exist" << endl;
     return;
   }

   TGeoIterator NodeIter(topvol);
   TGeoNode *node;
   NodeIter.SetType(0); // include  all daughters

   Double_t * volume = new Double_t[max_idx+1];
   Double_t * mass   = new Double_t[max_idx+1];

   for( Int_t i = 0; i<max_idx+1; i++ ){ volume[i]=0.; mass[i]=0.; } // IMPORTANT! force empty arrays, allows repated calls without ending ROOT session

   volume[ topvol->GetMaterial()->GetIndex() ] = topvol->Capacity() * volume_unit_to_SI; //iterator does not include topvolume  

   while ( (node=NodeIter()) )
   {
      Int_t momidx = node->GetMotherVolume()->GetMaterial()->GetIndex() ;
      Int_t idx    = node->GetVolume()      ->GetMaterial()->GetIndex() ;

      Double_t node_vol = node->GetVolume()->Capacity() * volume_unit_to_SI;

      volume[ momidx ] -= node_vol; //substract subvolume from mother
      volume[ idx    ] += node_vol;
   }


   Double_t larr_MassIsotopes[lcin_Z][lcin_A] = {0.}; //[Z][A], no map in pure ROOT
   Double_t larr_VolumeIsotopes[lcin_Z][lcin_A] = {0.}; //[Z][A], no map in pure ROOT

   for( Int_t i=0; i<gGeoManager->GetListOfMaterials()->GetEntries(); i++ )
   {
      TGeoMaterial *lgeo_Mat = gGeoManager->GetMaterial(i);
      Int_t    idx     = gGeoManager->GetMaterial(i)->GetIndex();

      if( lgeo_Mat->IsMixture() )
      {
         TGeoMixture * lgeo_Mix = dynamic_cast <TGeoMixture*> ( lgeo_Mat );
         Int_t lint_Nelements = lgeo_Mix->GetNelements();

         for ( Int_t j=0; j<lint_Nelements; j++) 
         {
            Int_t lint_Z = TMath::Nint( (Double_t) lgeo_Mix->GetZmixt()[j] );
            Int_t lint_A = TMath::Nint( (Double_t) lgeo_Mix->GetAmixt()[j] );
            Double_t ldou_Fraction = lgeo_Mix->GetWmixt()[j];
//.........这里部分代码省略.........
开发者ID:abercell,项目名称:GENIE_2_8,代码行数:101,代码来源:get_target_mass.C


注:本文中的TGeoVolume::GetMaterial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。